Skip Navigation

[Resolved] Nested conditionals in content template

This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 3 voices.

Last updated by UNC Digital Services 6 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1014436
Screen Shot 2018-07-30 at 3.11.21 PM.png

I am trying to:

I have a site on a multisite installation that is using a content template for a custom post type "Advertisements." The content template has conditionals for each of the seven different categories in the "Advertisements Types" taxonomy. The content template works fine except for two categories conditionals that also have another conditional inside of them. For only posts in the "solicitation-from-prequalified-contractor" and "public-meeting-notices" categories, the custom field shortcodes will not display their data, just the [types field="__"][/types] shortcode itself. I'm not sure if the nested conditionals are problem exactly, but the issue only occurs when there is nested conditionals.

Relevant code from the content template (the other category code is similar, just without nested conditionals):

<!-- CONSTRUTCION BID SOLICITATIONS FROM PRE-QUALIFIED CONTRACTORS -->
[wpv-conditional if="( '[wpv-post-taxonomy type="advertisement-type" format="slug"]' eq 'solicitation-from-prequalified-contractor')"]
<dl class="inline">
<dt>Project Name</dt> <dd>[types field='ad-project-name'][/types]</dd>
</dl> 
<strong>Bidding from prequalified firms on</strong>
<p>[types field='ad-bidding-from-prequalified-firms'][/types]</p>
<dl class="inline">
[wpv-conditional if="( $(wpcf-ad-main-contact) ne '' )"]<dt>Main Contact for Submission</dt><dd>[types field='ad-main-contact'][/types]</dd>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-ad-design-firm) ne '' )"]<dt>Name of Design Firm</dt><dd>[types field='ad-design-firm'][/types]</dd>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-ad-design-firm-contact-name) ne '' )"]<dt>Design Firm Contact Name</dt><dd>[types field='ad-design-firm-contact-name'][/types]</dd>[/wpv-conditional]
<dt>Design Firm Telephone Number</dt><dd>[types field='ad-design-firm-phone'][/types]</dd>
<dt>Design Firm Email</dt><dd>[types field='ad-design-firm-email'][/types]</dd>
<dt>CM at Risk Firm Name</dt><dd>[types field='ad-cmar-firm-name'][/types]</dd>      
<dt>CM at Risk Firm Contact</dt><dd>[types field='ad-cmar-firm-contact'][/types]</dd>
<dt>CM at Risk Firm Telephone Number</dt><dd>[types field='ad-cmar-firm-phone'][/types]</dd>
<dt>CM at Risk Firm Email</dt><dd>[types field='ad-cmar-firm-email'][/types]</dd>
<dt>Campus Contact Name</dt><dd>[types field='ad-campus-contact'][/types]</dd>
<dt>Campus Contact Telephone</dt><dd>[types field='ad-campus-contact-phone'][/types]</dd>
<dt>Campus Contact Email</dt><dd>[types field='ad-campus-contact-email'][/types]</dd>
<dt>Bid Date</dt><dd>[types field='ad-bid-date'][/types]</dd>
<dt>Bid Time</dt><dd>[types field='ad-bid-time'][/types]</dd>
</dl>
<strong>Bid Location</strong>  
<p>[types field='ad-bid-location'][/types]</p>
<p><strong>Advertisement Type:</strong>[wpv-post-taxonomy type="advertisement-type"]</p>  
[/wpv-conditional]

 <!-- PUBLIC MEETING NOTICES -!>-->
[wpv-conditional if="( '[wpv-post-taxonomy type="advertisement-type" format="slug"]' eq 'public-meeting-notices')"]
<dl class="inline">
<dt>Project Name</dt><dd> [types field='ad-project-name'][/types]</dd>
</dl>
<strong>Public Meeting For</strong>
<p>[types field='ad-public-meeting-for'][/types]</p>
<dl class="inline">
[wpv-conditional if="( $(wpcf-ad-design-firm) ne '' )"]<dt>Name of Design Firm</dt><dd> [types field='ad-design-firm'][/types]</dd>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-ad-design-firm-contact-name) ne '' )"]<dt>Design Firm Contact Name</dt><dd> [types field='ad-design-firm-contact-name'][/types]</dd>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-ad-design-firm-phone) ne '' )"]<dt>Design Firm Telephone Number</dt><dd> [types field='ad-design-firm-phone'][/types]</dd>[/wpv-conditional]
<dt>Contact Email</dt><dd> [types field='ad-contact-email'][/types]</dd>
[wpv-conditional if="( $(wpcf-ad-campus-contact-email) ne '' )"]<dt>Campus Contact Email</dt><dd> [types field='ad-campus-contact-email'][/types]</dd>[/wpv-conditional]
<dt>Public Meeting Date</dt><dd> [types field='ad-public-meeting-date'][/types]</dd>
<dt>Public Meeting Time</dt><dd> [types field='ad-public-meeting-time'][/types]</dd>
</dl>
  <strong>Public Meeting Location</strong>
  <p>[types field='ad-public-meeting-location'][/types]</p>
  <p><strong>Advertisement Type:</strong> [wpv-post-taxonomy type="advertisement-type"]</p>
[/wpv-conditional]

Link to a page where the issue can be seen: hidden link

I expected to see: Custom field data populated on the page

Instead, I got: Types field shortcode where custom field data should be displayed

#1021103

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Thank you for contacting our support forum.

Would you mind providing me with admin access so that I can take a look ?

The private fields will be enabled for your next response.

Thanks,
Shane

#1069514

Unfortunately I cannot give you admin access as this is a restricted login system from a university. Is there anything I can post to help you troubleshoot?

#1070327

Hi, Shane is on public holiday so I'll try to help. I've seen issues like this in certain versions of PHP, where our regex algorithms break down with medium to large blocks of content and conditionals, resulting in shortcodes written out to the page. As a quick test, can you turn off pcre.jit by adding this line to your php.ini file?

pcre.jit= 0

If you're not able to modify php.ini, you can try adding this line to your wp-config.php file:

ini_set('pcre.jit', false);

Give that a quick run and see if it makes any difference. If not, I'll be glad to take a closer look.

#1078635

Unfortunately that did not work, as this setting has been set to false since before the issue began.

#1078686

Actually, looks like we've solved the issue. We're not quite sure how exactly since we tried multiple options to fix the issue, but it may have been a plugin conflict or some errant code.

Thanks for the help.