Advertisement:

Author Topic: Custom Attributes Plugin - how to make basic amend  (Read 2747 times)

owain

  • Newbie
  • *
  • Posts: 14
Custom Attributes Plugin - how to make basic amend
« on: November 19, 2014, 01:48:12 pm »
Hello,

I have the Custom Attributes Plugin installed. I just want to be able to move the custom attributes up higher on the publish an Ad page, so that they are more connected to the General information on the product for sale rather than at the end of the location of the client. It makes more sense to me there. I just cannot fidn where to make the edit!

Any help or pointers would be great. Thanks
Owain

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom Attributes Plugin - how to make basic amend
« Reply #1 on: November 19, 2014, 06:33:44 pm »
Hi,

The solution may depend on the theme you're using, what is it? ???

Regards

owain

  • Newbie
  • *
  • Posts: 14
Re: Custom Attributes Plugin - how to make basic amend
« Reply #2 on: November 19, 2014, 06:54:10 pm »
Hello,

Thanks for your reply. Its bender.
Owain

owain

  • Newbie
  • *
  • Posts: 14
Re: Custom Attributes Plugin - how to make basic amend
« Reply #3 on: November 19, 2014, 06:57:48 pm »
I just couldnt work out how the plugin files meshed with the standard files and so I could not find where to start making an edit! I was working on the item-post.php file i think but the plugin code is located elsewhere. I wasn't sure how the plugin works - so maybe an xls file somewhere calls the standard code and then the plug extra code - but I could not locate it nor the plugin code :)
Thanks

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom Attributes Plugin - how to make basic amend
« Reply #4 on: November 19, 2014, 07:26:23 pm »
***CORRECTED***

No, I'll try to explain briefly the basic mechanism:

On item-post and item-edit code an empty div "plugin-hook" is inserted from the beginning. That div will be filled (via an an Ajax call) only when you select or change Category. It will contain both custom fields and any contents your active plugins need to add there.

So, to avoid modification in core files (that manage that Ajax call), you need to do this on the client side using Javascript. For that, a couple of hooks can be used. This should work:

Add this at the very bottom of your theme functions.php (take care not to leave blank lines after this):

Code: [Select]
<?php
function cust_move_custom_attributes() { ?>


<script type="text/javascript">
    $("#plugin-hook").change(function(){
        $("<div></div>").attr('id', 'moved_custom_attributes').insertAfter($("input#price").parent("div.controls"));
        $("#moved_custom_attributes").append($("#custom_attributes"));
    });
</script>

<?php }

$section Rewrite::newInstance()->get_section();
if (
$section == 'item_add' || $section == 'item_edit'osc_add_hook('footer''cust_move_custom_attributes');

function 
cust_trigger_plugin_hook() { ?>


<script type="text/javascript">
    $("#moved_custom_attributes").remove();
    $("#plugin-hook").change();
</script>

<?php }

osc_add_hook('item_form''cust_trigger_plugin_hook''6');
osc_add_hook('item_edit''cust_trigger_plugin_hook''6');
?>

Regards

« Last Edit: November 19, 2014, 10:18:47 pm by teseo »

owain

  • Newbie
  • *
  • Posts: 14
Re: Custom Attributes Plugin - how to make basic amend
« Reply #5 on: November 19, 2014, 07:46:14 pm »
Hello,

Thanks so much for taking the time to do this, I did put the code right at the end of the functions.php file in the bender dir. but it seemed to make no difference :(

I dont know java too well and can only pick around with php so not sure I can debug it.
Thanks
Mark

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom Attributes Plugin - how to make basic amend
« Reply #6 on: November 19, 2014, 08:30:41 pm »
Hm... It ¡s working here, but the again there are a few things that might be different between your installation and mine...

Please tell me:

- Your Osclass version.
- Your Bender version.
- Your Custom Attributes version.

(For theme and plugin you may see that info on the first lines of their index.php)

Regards

owain

  • Newbie
  • *
  • Posts: 14
Re: Custom Attributes Plugin - how to make basic amend
« Reply #7 on: November 19, 2014, 09:37:02 pm »
Hello! Thanks for that.

OSclass ver:  Osclass 3.4.3
Bender:  Version: 2.0.1
cust Attr:  Version: 1.0.0

Thanks,
Owain

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom Attributes Plugin - how to make basic amend
« Reply #8 on: November 19, 2014, 10:20:04 pm »
My mistake, a syntax error. This line:

Code: [Select]
if ($section == 'item_add' || $section == 'item_edit') osc_add_hook('footer', 'custom_attributes');
must be:

Code: [Select]
if ($section == 'item_add' || $section == 'item_edit') osc_add_hook('footer', 'cust_move_custom_attributes');
Regards

owain

  • Newbie
  • *
  • Posts: 14
Re: Custom Attributes Plugin - how to make basic amend
« Reply #9 on: November 20, 2014, 02:09:54 am »
Thanks for this - I updated that but it the attributes still seem to be at the bottom of the page. :(
Thanks

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom Attributes Plugin - how to make basic amend
« Reply #10 on: November 20, 2014, 02:33:53 am »
Then I'm out of ideas. I can see it working perfectly here using same versions as you. ???

Regards

owain

  • Newbie
  • *
  • Posts: 14
Re: Custom Attributes Plugin - how to make basic amend
« Reply #11 on: November 20, 2014, 11:47:43 am »
OK - thanks. Tghanks so much for taking the time.

 Thats so strange! So the code is right at the end of the functions.php file in themes/bender/  ?

I just want to check I have it in the same place as you.
Thanks
Owain


owain

  • Newbie
  • *
  • Posts: 14
Re: Custom Attributes Plugin - how to make basic amend
« Reply #12 on: November 20, 2014, 11:58:19 am »
I don't understand why that's not worked on my setup. I did wonder if it might be because I had made one change to the functions.php (to add category images), so just tried it with the original functions.php file and code change above and still no joy  :(
I suppose another plugin might be interfering.
Owain

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom Attributes Plugin - how to make basic amend
« Reply #13 on: November 20, 2014, 02:09:29 pm »
It occurred to me that I'm using Price input to find a destination div inside General Information block, but that Price input is optional depending on Category settings, so this modification will check first for existence of Price input. If not found, it will use Description textarea (always mandatory) as destination.

Maybe this is what is happening to you. ??? In any case, it's a needed enhancement:

Add this at the very bottom of your theme functions.php (take care not to leave blank lines after this):

Code: [Select]
<?php
function cust_move_custom_attributes() { ?>


<script type="text/javascript">
    $("#plugin-hook").change(function(){

        if ($("input#price").length) {
            var elemReference = $("input#price");
        } else {
            var elemReference = $("[id^=description]").last();
        }

        $("<div></div>").attr('id', 'moved_custom_attributes').insertAfter(elemReference.parent("div.controls"));
        $("#moved_custom_attributes").append($("#custom_attributes"));
    });
</script>

<?php }

$section Rewrite::newInstance()->get_section();
if (
$section == 'item_add' || $section == 'item_edit'osc_add_hook('footer''cust_move_custom_attributes');

function 
cust_trigger_plugin_hook() { ?>


<script type="text/javascript">
    $("#moved_custom_attributes").remove();
    $("#plugin-hook").change();
</script>

<?php }

osc_add_hook('item_form''cust_trigger_plugin_hook''6');
osc_add_hook('item_edit''cust_trigger_plugin_hook''6');
?>

Regards

ronnnie

  • Jr. Member
  • **
  • Posts: 89
Re: Custom Attributes Plugin - how to make basic amend
« Reply #14 on: November 27, 2014, 06:03:42 am »
hello teseo, making you a question again.  I tested your code with synmel theme, but does not work, I can make some modification to work?
There is a function to display custom-attributes 
Code: [Select]
<? php if (function_exists ('custom_attributes')) custom_attributes ();?>I can remove with something like this?
Code: [Select]
<php osc_remove_hook ('item_detail', 'custom_attributes')? ;?>and show in any place with this?
Code: [Select]
<? php if (function_exists ('custom_attributes')) custom_attributes ();?>

thanks for advance.