• Resolved jiipsijack

    (@jiipsijack)


    I have the extra fields module and awpcp 3.0.1 installed on my wordpress site, I’ve added two extra fields into my listings, one for physical address, into which I’ve added a section of code to convert that field into a google maps link like so
    $html .= ”;
    } else if (count($value) > 0) {
    $value = awpcp_extra_fields_render_field_single_value($field, $value[0]);
    $html .= sprintf( ‘<span class=”awpcp-extra-field-value”><address>%s</address></span>’, $value );
    this also uses the convert address to google maps link plugin.
    Now I’ve added a second extra field called keywords, I was hoping to change the field name and value to the same color as the background so they aren’t on my listings looking messy but will still be recognized by the search form. My problem is that awpcp extra fields php file doesn’t differentiate between one field and another, so the address coding is affecting my keywords field and if I were to hide my keywords field I would also be hiding the address field. Is there any way of differentiating between different fields? for example some type of Query against row number etc?

    Thanks in advance.

    https://www.ads-software.com/plugins/another-wordpress-classifieds-plugin/

Viewing 11 replies - 1 through 11 (of 11 total)
  • HI jiipsijack,

    My developer is out on vacation for a bit so I’ll have to defer this to him when he returns.

    Thread Starter jiipsijack

    (@jiipsijack)

    Thanks for such a prompt reply, I look forward to hearing from him.

    Thread Starter jiipsijack

    (@jiipsijack)

    Hi there, Sorry to inundate but I see that your developer is back as other support queries have been resolved, was just wondering whether any ground has been made on this? Really need to get it sorted and I can’t figure it out by myself unfortunately, Thanks Again.

    Got an answer for you here:

    Is there any way of differentiating between different fields? for example some type of Query against row number etc?

    Unfortunately we don’t have a way to control the output of individual fields of the same type (I believe he is using two textfields). However, since he is already modifying the plugin’s code, he can use $field->field_name to check which field is being processed and apply the google maps modifications to one field and the keyword modifications to the other.

    Thread Starter jiipsijack

    (@jiipsijack)

    Hi there, thanks again for your reply, while I appreciate your confidence in my coding abilities, unfortunately I’m not certain how to use $field->field_name to differentiate the fields. I see this line 30 times in awpcp_extra_fields_module.php. If you could tell me how to use it to see which field is being processed I’m sure I could figure the rest out with that as a starting point. And you are correct, it is two text fields.

    Thanks in advance.

    Hi jiipsijack,

    If the code aspect seems a bit daunting, we would recommend that you hire a developer on oDesk to help with this kind of customization. There are a number of PHP/WordPress guys on there at reasonable prices: https://odesk.com

    Thread Starter jiipsijack

    (@jiipsijack)

    It doesn’t seem daunting, all I really need is a starting point so if you wouldn’t mind explaining how to use the $field->field_name to differentiate, I’m sure I can figure the rest out myself. Thanks once again for your time.

    The field name is the name of the field defined in your AWPCP Extra Fields admin. So you’d have to use some kind of conditional in the code to customize the behavior or output per field. Something like this:

    if ($field->field_name == "my_field") {
    //Do map-specific for just my_field
    }
    else {
    //Regular output for other fields
    }
    Thread Starter jiipsijack

    (@jiipsijack)

    Fantastic! Thank you so much for your help, The support for this plugin really is great. I’ll give this a whirl and let you know how it works out.

    Thread Starter jiipsijack

    (@jiipsijack)

    It’s worked! I’ve differentiated between fields now and my address field is showing up as a link while my keywords field is showing up hidden in listings, just like I wanted

    For anyone else trying something similar the code I used looks like:

    `else if (count($value) > 0 && $field->field_name == “address”) {
    $value = awpcp_extra_fields_render_field_single_value($field, $value[0]);
    $html .= sprintf( ‘<span class=”awpcp-extra-field-value”><address>%s</address></span>’, $value );
    } else if (count($value) > 0 && $field->field_name == “keywords”) {
    $value = awpcp_extra_fields_render_field_single_value($field, $value[0]);
    $html .= sprintf( ‘<span class=”awpcp-extra-field-value”><font color=”white”>%s</font></span>’,`

    However I didn’t realise that the search form doesn’t recognise the content of extra fields unless I have a search section specifically for that. Is there any way that I can change the search form so it will read from “ad title” “ad details” and my extra field? If you like I can start a new Forum question as this is sort of a different question now.

    Yes, please start a new thread for this. And when you do, please post a screenshot of what you are seeing on your search screen.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Applying different coding to extra fields.’ is closed to new replies.