Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I hope this is the right place to post this. I'm using Addresses to make a simple CRM and have set my Addresses format as follows:
[addresses_aname_hcard] [addresses_is_primary_hcard]
[addresses_street_hcard]
[addresses_city_hcard], [addresses_province_name_hcard] [addresses_postal_code_hcard]
[addresses_country_name_hcard]
Phone: [addresses_phone_plain]<br/>
Fax: [addresses_fax_plain]<br/>
Toll free: [addresses_additional_plain]
I'm using the "Additional" field for a Toll Free phone number and I would like to insert a conditional to only show that field when it contains data. Is there a way to do that?
Thanks,
Andrew
Comments
Comment #1
AlexisWilke CreditAttribution: AlexisWilke commentedHi Andrew,
Unfortunately, no... there is no condition support. However I agree that would be nice.
Thank you.
Alexis Wilke
Comment #2
awasson CreditAttribution: awasson commentedHi Alexis,
Thanks for the reply. Maybe in a future update it will be added. If I come up with a patch, I'll be sure to post it. In the meantime I've come up with a workaround using jQuery. It's pretty easy and works as follows:
I changed my addresses formats so that the field I want to show or hide is wrapped in a div with a class that I can identify it with (class="toll-free").
Then I added some jQuery to the header of my view to loop through all of the divs that have that class. If they only contain the text "Toll free", I clear the text.
Pretty simple but it does the job.
Cheers,
Andrew
Comment #3
AlexisWilke CreditAttribution: AlexisWilke commentedThank you for sharing! 8-)
Alexis