Skip Navigation

[Resolved] Conditional Logic for Title doesn't seem to work

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 replies, has 2 voices.

Last updated by jacobB-3 1 year, 12 months ago.

Assisted by: Waqar.

Author
Posts
#2346525

Hello,

I'm using Toolset for faculty and staff listings on a new academic website - hidden link (in development).

We have a People page on the site for all people associated with this centre (hidden link)

For some of the people pages, the "Areas of Research" section shows up at the bottom with words that describe the person's research (field slug: areas-of-research). For example, Jennifer Davis' listing works well: hidden link

But for staff who are not researchers, I wasn't able to make the "Areas of Research" title disappear. For example: hidden link Since the areas-of-research is blank for these staff members, the title should disappear too.

The conditional shortcode I used didn't seem to get rid of the title. Can you help?

cheers,
Jacob

#2346777

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Jacob,

Thank you for contacting us and I'd be happy to assist.

You can wrap the heading and the shortcode for the "areas-of-research" field inside a conditional output so that they both show only if the field's value is not empty.

For example:


[wpv-conditional if="( NOT(empty($(areas-of-research))) )"]
<h2>Areas of Research</h2>
[types field='areas-of-research'][/types]
[/wpv-conditional]

Here is a guide on the topic of using the conditional output:
https://toolset.com/documentation/legacy-features/views-plugin/checking-fields-and-other-elements-for-emptynon-empty-values/

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2347075

Waqar,

Thanks for that suggestion. When I add these conditionals, they don't seem to work - instead the shortcodes appear in the listing.
For example, on this listing, you'll see the conditional shortcodes at the bottom and the "Areas of Research" title hasn't disappeared: hidden link

Is there something that is keeping these shortcodes from working?

cheers,
Jacob

#2348565

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back.

It looks like the code was added in the text editor, in the "Visual" mode and not the "Text" mode.

Can you please make sure that the code has been added in the "Text" mode and that there are no extra spaces, lines, or characters within it?
( screenshot: hidden link )

In case the issue still persists, you're welcome to share temporary admin login details, in reply to this message.

Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

#2349349

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing the admin access.

During troubleshooting, I noticed that the conditional shortcode isn't working on your website, because the Toolset Blocks plugin isn't active.

To make this work, you can activate the Toolset Blocks plugin and it should work. If for some reason, you'd prefer not to activate the Toolset Blocks plugin, you can update the code in the template to:


<h2 style="sans-serif; color: #205184; font-size: 24px; font-weight: 400; margin-top: 0px; margin-bottom: 0px;">Areas of Research</h2>
<p id="areas-of-research">[types field='areas-of-research'][/types]</p>

And next in the template's javascript editor ( screenshot: hidden link ), include the following script, that hides the heading "Areas of Research", when the field's text is empty:


jQuery(document).ready(function($){

if ($('p#areas-of-research').is(':empty')) { 
    $('p#areas-of-research').parent('.fl-rich-text').hide();
}

});

#2349819

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.