Skip Navigation

[Resuelto] Nested Conditional Cause Short Code to Fail

This support ticket is created hace 4 años, 10 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por Waqar hace 4 años, 10 meses.

Asistido por: Waqar.

Autor
Mensajes
#1445145
toolset-shorts.JPG

I am trying to:
Nest Conditonal Fields

Link to a page where the issue can be seen:
Restricted

I expected to see:
My Fields for Products where Component Set is the Speaker Type

Instead, I got:
See Image

Here's My Nesting Structure...

[wpv-conditional if="('[wpv-post-taxonomy type='speaker-type' format='slug' ]' eq 'component-set' )"]

<div class="uk-align-center uk-width-5-6@l">
	
	<div class="uk-grid-column-medium uk-grid-row-medium uk-child-width-expand@s" uk-grid>
  
		[wpv-conditional if="( $(wpcf-midrange-model-number) ne '' )"]
  
		<div>
			<h4 class="uk-text-center uk-align-center">[types field='midrange-model-number'][/types]</h4>  
			<table class="uk-table uk-table-striped uk-table-hover">
    			<thead>
        			<tr>
            			<th></th>
        			</tr>
    			</thead>
    			<tbody>
		
				[wpv-conditional if="( $(wpcf-midrange-driver-size-inches-mm) ne '' )"]      
        			<tr>
	            		<td><strong>Driver Size:</strong></td>
            			<td><span class="uk-align-right">[types field='midrange-driver-size-inches-mm'][/types]</span></td>
        			</tr>
				[/wpv-conditional]
		
				[wpv-conditional if="( $(wpcf-midrange-watts-rms) ne '' )"]
					<tr>
				    	<td><strong>Watts RMS:</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-watts-rms'][/types]</span></td>
				    </tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-peak-power) ne '' )"]
					<tr>
				    	<td><strong>Peak Power:</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-peak-power'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-vcd) ne '' )"]
					<tr>
				    	<td><strong>Voice Coil Diameter (Inches):</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-vcd'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-vcd-mm) ne '' )"]
				    <tr>
				    	<td><strong>Voice Coil Diameter (MM):</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-vcd-mm'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-impedance) ne '' )"]
				    <tr>
				    	<td><strong>Impedance:</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-impedance'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-freq-res-hz) ne '' )"]
					<tr>
				    	<td><strong>Frequency Response (Hz):</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-freq-res-hz'][/types]</span></td>
				    </tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-fs-hz) ne '' )"]
					<tr>
				    	<td><strong>Fs (Hz):</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-fs-hz' output='raw'][/types]</span></td>
				    </tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-qms) ne '' )"]
				    <tr>
				        <td><strong>Qms:</strong></td>
				    	<td><span class="uk-align-right">[types field='midrange-qms' output='raw'][/types]</span></td>
				    </tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-qes) ne '' )"]
					<tr>
				    	<td><strong>Qes:</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-qes' output='raw'][/types]</span></td>
				    </tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-qts) ne '' )"]
					<tr>
				    	<td><strong>Qts:</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-qts' output='raw'][/types]</span></td>
				    </tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-vas-liters) ne '' )"]
				    <tr>
						<td><strong>Vas (Liters):</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-vas-liters' output='raw'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-dbspl) ne '' )"]
				    <tr>
						<td><strong>dBSPL:</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-dbspl' output='raw'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-mounting-diameter-inches) ne '' )"]
				    <tr>
						<td><strong>Mounting Diameter (In):</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-mounting-diameter-inches'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-mounting-diameter-mm) ne '' )"]
				    <tr>
				    	<td><strong>Mounting Diameter (MM):</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-mounting-diameter-mm'][/types]</span></td>
				    </tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-mounting-depth-inches) ne '' )"]
				    <tr>
				        <td><strong>Mounting Depth (In):</strong></td>
				    	<td><span class="uk-align-right">[types field='midrange-mounting-depth-inches'][/types]</span></td>
				    </tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-midrange-mounting-depth-mm) ne '' )"]
					<tr>
				    	<td><strong>Mounting Depth (MM):</strong></td>
				        <td><span class="uk-align-right">[types field='midrange-mounting-depth-mm'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				</tbody>

			</table>
		
		</div>

		[/wpv-conditional]	
	

		[wpv-conditional if="( $(wpcf-tweeter-model-number) ne '' )"]	
		
		<div>

			<h4 class="uk-text-center uk-align-center">[types field='tweeter-model-number'][/types]</h4>  

			<table class="uk-table uk-table-striped uk-table-hover">
    
				<thead>
        			<tr>
           				<th></th>
        			</tr>
    			</thead>
    		
				<tbody>
		
				[wpv-conditional if="( $(wpcf-tweeter-driver-size-inches-mm) ne '' )"]      
					<tr>
						<td><strong>Driver Size:</strong></td>
					    <td><span class="uk-align-right">[types field='tweeter-driver-size-inches-mm'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-tweeter-watts-rms) ne '' )"]
					<tr>
					    <td><strong>Watts RMS:</strong></td>
					    <td><span class="uk-align-right">[types field='tweeter-watts-rms'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-tweeter-peak-power) ne '' )"]
					<tr>
					    <td><strong>Peak Power:</strong></td>
					    <td><span class="uk-align-right">[types field='tweeter-peak-power'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-tweeter-vcd-in) ne '' )"]
					<tr>
					    <td><strong>Voice Coil Diameter (Inches):</strong></td>
					    <td><span class="uk-align-right">[types field='tweeter-vcd-in'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-tweeter-vcd-mm) ne '' )"]
					<tr>
					    <td><strong>Voice Coil Diameter (MM):</strong></td>
					    <td><span class="uk-align-right">[types field='tweeter-vcd-mm'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-tweeter-impedance) ne '' )"]
					<tr>
					    <td><strong>Impedance:</strong></td>
					    <td><span class="uk-align-right">[types field='tweeter-impedance'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-tweeter-freq-res-hz) ne '' )"]
					<tr>
					    <td><strong>Frequency Response (Hz):</strong></td>
					    <td><span class="uk-align-right">[types field='tweeter-freq-res-hz'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-tweeter-dbspl) ne '' )"]
					<tr>
					    <td><strong>dBSPL:</strong></td>
					    <td><span class="uk-align-right">[types field='tweeter-dbspl' output='raw'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-tweeter-mounting-diameter-inches) ne '' )"]
					<tr>
					    <td><strong>Mounting Diameter (In):</strong></td>
					    <td><span class="uk-align-right">[types field='tweeter-mounting-diameter-inches'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-tweeter-mounting-diameter-mm) ne '' )"]
					<tr>
					    <td><strong>Mounting Diameter (MM):</strong></td>
					    <td><span class="uk-align-right">[types field='tweeter-mounting-diameter-mm'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-tweeter-mounting-depth-inches) ne '' )"]
					<tr>
					    <td><strong>Mounting Depth (In):</strong></td>
					    <td><span class="uk-align-right">[types field='tweeter-mounting-depth-inches'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-tweeter-mounting-depth-mm) ne '' )"]
					<tr>
					    <td><strong>Mounting Depth (MM):</strong></td>
					    <td><span class="uk-align-right">[types field='tweeter-mounting-depth-mm'][/types]</span></td>
					</tr>
				[/wpv-conditional]
		
				</tbody>

			</table>
	
		</div>

		[/wpv-conditional]
	

		[wpv-conditional if="( $(wpcf-crossover-model-number) ne '' )"]	

		<div>

			<h4 class="uk-text-center uk-align-center">[types field='crossover-model-number'][/types]</h4>  
		
			<table class="uk-table uk-table-striped uk-table-hover">
    
				<thead>
        
					<tr>
            			<th></th>
        			</tr>
    			</thead>
    			<tbody>
		
				[wpv-conditional if="( $(wpcf-sp-input-channels) ne '' )"]      
					<tr>
					    <td><strong>Input Channels:</strong></td>
					    <td><span class="uk-align-right">[types field='sp-input-channels'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-sp-output-channels) ne '' )"]      
					<tr>
					    <td><strong>Output Channels:</strong></td>
					    <td><span class="uk-align-right">[types field='sp-output-channels'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-sp-dimensions-in) ne '' )"]      
					<tr>
					    <td><strong>Dimensions (Inches):</strong></td>
					    <td><span class="uk-align-right">[types field='sp-dimensions-in'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				[wpv-conditional if="( $(wpcf-sp-dimensions-mm) ne '' )"]      
					<tr>
					    <td><strong>Dimensions (MM):</strong></td>
					    <td><span class="uk-align-right">[types field='sp-dimensions-mm'][/types]</span></td>
					</tr>
				[/wpv-conditional]
						
				</tbody>
			
			</table>
					
		</div>

		[/wpv-conditional]
	
	</div>

</div>  

[/wpv-conditional]
#1445155

I forgot to mention...

If the top level conditional code (below) is not there, it works fine AND the code kind of works, because if "component-set" is changed to "component-se" the entire block disappears.

The problem is that it returns the actual short codes.

[wpv-conditional if="('[wpv-post-taxonomy type='speaker-type' format='slug' ]' eq 'component-set' )"]
#1446025

Hi Shawn,

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

A shortcode parsing issue like this can be experienced if long content is enclosed inside the conditional shortcode block "wpv-conditional".

This limitation is not something specific to Toolset plugins, but it is related to how shortcodes are parsed by WordPress in general and the server's PHP configuration. A note about this is also included on our documentation and in the errata:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://toolset.com/errata/shortcodes-in-conditionally-displayed-content-may-not-be-executed-on-the-front-end/

When this is only happening on a specific server, you can follow any of these steps to fix it:

1. You can break up the longer content that is wrapped in a single conditional block, to smaller conditional blocks.

2. If that is not possible or ideal, you can test with "PCRE JIT" disabled via "wp-config.php" file.

In the file "wp-config.php", you can include the following line, just before the line "That's all, stop editing!":


ini_set('pcre.jit', false);

For more information on "PCRE JIT", you can check out the following links or consult your host's support team:

enlace oculto
enlace oculto

3. If for some reason, options 1 & 2 are not possible or don't work, you can follow a simpler workaround of hiding the content inside the top-level conditional block through a special div wrapper, which can show or hide the view's content conditionally:


[wpv-conditional if="('[wpv-post-taxonomy type='speaker-type' format='slug' ]' ne 'component-set' )"]
<div class="hidden">
[/wpv-conditional]

.....Inner content....
 
[wpv-conditional if="('[wpv-post-taxonomy type='speaker-type' format='slug' ]' ne 'component-set' )"]
</div>
[/wpv-conditional]

As a result, the inner content will be wrapped inside a div with class "hidden", whenever the taxonomy's slug is not equal to "component-set" and you can hide that div through custom CSS code.


.hidden {
    display: none !important;
}

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

regards,
Waqar

#1446745

Excellent solution, I should have thought of that!

#1448091

Glad my message helped and please let me know if you have any follow-up or related questions.

For a new question or concern, you're welcome to start a new ticket.