Skip Navigation

[Resolved] Conditional output does not work possibly due to aria conflict?

This support ticket is created 4 years, 4 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.

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)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by catrionaD 4 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1729265

I am trying to:
Conditionally display the recommendation textbox section if the recommendation text is not empty.

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

I expected to see:
For the coronavirus masks post, there is no recommendation text, so the recommendation text box should not be visible.

Instead, I got:
You can see the recommendation text box for that post.

<div class="selfhelplistingarea">
	<div class="row">
		<div class="col-sm-4">
		<a href ="[types field='product-url' output='raw' target='blank' rel='noopener noreferrer' class="selfhelp-header1"][/types]"target='blank' rel='noopener noreferrer' >[wpv-post-featured-image size="medium"]</a>
		</div>  
		<div class="col-sm-8">
			<div class="selfhelp-header1">
			<a href ="[types field='product-url' output='raw' target='blank' rel='noopener noreferrer' class="selfhelp-header1"][/types]"target='blank' rel='noopener noreferrer' >[types field='product-title'][/types]</a>
			</div>
			<div class ="selfhelp-details">[types field='author-provider'][/types]  <p class="mobile-para"></p>[types field='product-price' class ="contact"][/types]<p class="mobile-para"></p><a href ="[types field='product-url' output='raw' target='blank' rel='noopener noreferrer'][/types]"target='blank' rel='noopener noreferrer' class="selfhelp-header1">     Buy from [types field='retailer' class="selfhelp-header-link"][/types] <i class="fas fa-external-link-alt"></i></a>
			</div>
          	<div id="module" class="container">
  			<p class="collapse" id="collapse-[wpv-post-id]" aria-expanded="false"><b>Description: </b>[types field='product-description' output='raw'][/types]</p>
			<a role="button" class="collapsed" data-toggle="collapse" href="#collapse-[wpv-post-id]" aria-expanded="false" aria-controls="collapse"></a>
			</div>
          [wpv-conditional if="( NOT(empty($(wpcf-recommendation-text))) )"]
            <div class="recommendationarea"> 
              <div id="module" class="container">
  			<p class="collapse" id="collapse-[wpv-post-id]-[wpv-post-id]" aria-expanded="false"><i class="fas fa-user-circle"></i> <b>Recommended by [types field='suggested-by' class ="reco"][/types]: </b>"[types field='recommendation-text' output='raw'][/types]"</p>
            <a role="button" class="collapsed" data-toggle="collapse" href="#collapse-[wpv-post-id]-[wpv-post-id]" aria-expanded="false" aria-controls="collapse"></a>
			</div>
          </div> 
          [/wpv-conditional]
       	</div>
	</div>                 	
</div> 
#1729935

Hello, can you turn on debug for this conditional temporarily, and test again?

...
[wpv-conditional if="( NOT(empty($(wpcf-recommendation-text))) )" debug="true"]
...

Let me know what is displayed in the debug information for the Corona masks post. Also, what type of field is recommendation-text?

#1730939

Hi Christian,

Thanks for your help - that is the debug on and the same issue occurs.

Recommendation-text is a single line custom field.

#1731445

Thanks for your help - that is the debug on and the same issue occurs.
Okay when you turn on debug, there should be some technical information output on the front-end of the site. I need to see that information, but I can't find it on the front-end now. Did you turn off debug? Can you turn it on temporarily and copy the output for this post, then include that in your next reply?

If debug is currently "on" but there is no output generated, please try this alternative syntax:

[wpv-conditional if="('[types field="recommendation-text" output="raw"][/types]' ne '' )" debug="true"]
#1731809

Hi Christian, I still had the original debug on when you checked - the debug information was not shown.
I replaced this with your new syntax, but still the debug information is not shown (this syntax is still in place).

<div class="selfhelplistingarea">
	<div class="row">
		<div class="col-sm-4">
		<a href ="[types field='product-url' output='raw' target='blank' rel='noopener noreferrer' class="selfhelp-header1"][/types]"target='blank' rel='noopener noreferrer' >[wpv-post-featured-image size="medium"]</a>
		</div>  
		<div class="col-sm-8">
			<div class="selfhelp-header1">
			<a href ="[types field='product-url' output='raw' target='blank' rel='noopener noreferrer' class="selfhelp-header1"][/types]"target='blank' rel='noopener noreferrer' >[types field='product-title'][/types]</a>
			</div>
			<div class ="selfhelp-details">[types field='author-provider'][/types]  <p class="mobile-para"></p>[types field='product-price' class ="contact"][/types]<p class="mobile-para"></p><a href ="[types field='product-url' output='raw' target='blank' rel='noopener noreferrer'][/types]"target='blank' rel='noopener noreferrer' class="selfhelp-header1">     Buy from [types field='retailer' class="selfhelp-header-link"][/types] <i class="fas fa-external-link-alt"></i></a>
			</div>
          	<div id="module" class="container">
  			<p class="collapse" id="collapse-[wpv-post-id]" aria-expanded="false"><b>Description: </b>[types field='product-description' output='raw'][/types]</p>
			<a role="button" class="collapsed" data-toggle="collapse" href="#collapse-[wpv-post-id]" aria-expanded="false" aria-controls="collapse"></a>
			</div>
[wpv-conditional if="('[types field="recommendation-text" output="raw"][/types]' ne '' )" debug="true"]
          <div class="recommendationarea"> 
              <div id="module" class="container">
  			<p class="collapse" id="collapse-[wpv-post-id]-[wpv-post-id]" aria-expanded="false"><i class="fas fa-user-circle"></i> <b>Recommended by [types field='suggested-by' class ="reco"][/types]: </b>"[types field='recommendation-text' output='raw'][/types]"</p>
            <a role="button" class="collapsed" data-toggle="collapse" href="#collapse-[wpv-post-id]-[wpv-post-id]" aria-expanded="false" aria-controls="collapse"></a>
			</div>
          </div> 
          [/wpv-conditional]
       	</div>
	</div>                 	
</div> 
#1732493

Something else must be going on, the debug information should be displayed here. May I log in and take a closer look?

#1733619

I think there has been a disconnect somewhere, because the conditional is not placed in the template that is currently displayed in the View's loop. Please follow along:
First, I edit the page we are discussing:
hidden link
Then I click to edit in Elementor, and I am redirected here:
hidden link
The page contains a View "Product listings 2 view". I can go to Toolset > Views to find the View, and edit the View here:
hidden link
If you look in the Loop Editor, you can see a Content Template is placed in the loop. That Content Template has a slug "selfcare-products-2". Just below the Loop Editor, I can see a different template is linked to the View. That is NOT the template placed in the loop, just to be clear. This usually happens when you manually change the contents in the Loop Editor to use a different template than the one that was originally designed in the View's Loop Wizard. So do not click "Edit with Block Editor", that will not change the results in the View. Instead, go to Toolset > Content Templates and edit the Selfcare products 2 template, and you can edit the selfcare-products-2 template here:
hidden link
I can't see the conditional anywhere in this code. My guess you're editing a similar template somewhere instead of the correct template. Please add the conditional in this template and check the results again, or update the View's loop editor to point to the correct template you want to use.

#1734803

My issue is resolved now. Thank you!