Skip Navigation

[Resolved] Conditionals based on Checkbox Working in Loop Editor but not Loop Item

This support ticket is created 6 years, 1 month 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
- 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 2 replies, has 2 voices.

Last updated by Waqar 6 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#1124871

I am trying to:
Have my Checkbox fields (NOT Checkboxes) determine which columns of Types Field data to display. Based on the setup in the Loop editor, If the Types Checkbox is checked then the a heading and column appears for that table of data appears. If the Checkbox is unchecked, then there is no heading or column in the table.

This is the Loop Editor code which works perfectly:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<table width="100%">
		<thead>
			<tr>
				[wpv-conditional if="( $(wpcf-title-x) eq 'Title' )"]<th>[wpv-heading name="types-field-title"]Title[/wpv-heading]</th>[/wpv-conditional]
				[wpv-conditional if="( $(wpcf-dop-x) eq 'DOP' )"]<th>[wpv-heading name="types-field-dop"]DOP[/wpv-heading]</th>[/wpv-conditional]
				[wpv-conditional if="( $(wpcf-director-x) eq 'Director' )"]<th>[wpv-heading name="types-field-director"]Director[/wpv-heading]</th>[/wpv-conditional]
				[wpv-conditional if="( $(wpcf-production-x) eq 'Production' )"]<th>[wpv-heading name="types-field-production"]Production[/wpv-heading]</th>[/wpv-conditional]
				[wpv-conditional if="( $(wpcf-camera-operator-x) eq 'Camera Operator' )"]<th>[wpv-heading name="types-field-camera-operator"]Camera Operator[/wpv-heading]</th>[/wpv-conditional]
				[wpv-conditional if="( $(wpcf-role-x) eq 'Role' )"]<th>[wpv-heading name="types-field-role"]Role[/wpv-heading]</th>[/wpv-conditional]
				[wpv-conditional if="( $(wpcf-completion-date-x) eq 'Date' )"]<th>[wpv-heading name="types-field-completion-date"]Completion Date[/wpv-heading]</th>[/wpv-conditional]
			</tr>
		</thead>
		<tbody class="wpv-loop js-wpv-loop">
		<wpv-loop>
			<tr>
				[wpv-post-body view_template="Loop item in Credit Detail"]
			</tr>
		</wpv-loop>
		</tbody>
	</table>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

This is the Loop Item Code in which the same conditionals which work in the Loop Editor above do not work in the Loop Item content template:

[wpv-conditional if="( $(wpcf-title-x) eq 'Title' )"]<td>[types field="title"][/types]</td>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-dop-x) eq 'DOP' )"]<td>[types field="dop"][/types]</td>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-director-x) eq 'Director' )"]<td>[types field="director"][/types]</td>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-production-x) eq 'Production' )"]<td>[types field="production"][/types]</td>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-camera-operator-x) eq 'Camera Operator' )"]<td>[types field="camera-operator"][/types]</td>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-role-x) eq 'Role' )"]<td>[types field="role"][/types]</td>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-completion-date-x) eq 'Date' )"]<td>[types field="completion-date"][/types]</td>[/wpv-conditional]

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

I expected to see:
I expected the conditionals to display the data and hide the unchecked columns as has been done in the headings.

Instead, I got:
No Types field data displayed whatsoever at the bottom page in the table columns. When I remove the conditionals all the Types field data appears disregarding the requirement that only data corresponding the column headings should appear.

Your help is appreciated...

#1125327

Hi Andrew,

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

If you're referring to your view "Credit Detail", it only holds information about nested repeating field group "Credit Detail" inside the loop.

The field values like "wpcf-title-x", "wpcf-dop-x" are not directly attached to this child relative, but are associated with the parent post. This is the reason, the conditions are not working when called inside the loop.

To get the values from the parent post (repeating field group), some custom code will be required, but that will require some further testing and troubleshooting.

Would it be possible for you to share a clone or snapshot of your website with us?
(it can be from this website or from another test website with the same custom post types and repeating field groups structure)

We usually recommend the free Plugin “Duplicator” (http://wordpress.org/plugins/duplicator/) for this porpoise.

If you already know how Duplicator works, you can skip the instruction video and just send me the installer file and the zipped package you downloaded.

Duplicator Instructions:
hidden link

( note: I'll need both files and you'll probably want to use DropBox, Google Drive, or similar services, as the snapshot file will be quite big )

IMPORTANT: Remember to create or keep an admin account for me before creating the snapshot, or I won’t be able to log in. You may delete the new admin account once the snapshot has been built.

I've set your next answer as private so you can provide me the information securely.

Please let us know if you have any further information or questions.

regards,
Waqar

#1126097
#1126110

Hi Andrew,

I made few minor changes in the template editor section, while testing but all of them were reverted back.

The link to post ids ( screenshot: hidden link ) were already showing, when I started looking.

These are being included through a [wpv-post-link] shortcode in, the "Loop Editor" field of view "Credit Detail".
( screenshot: hidden link )

I've checked the CV post type with title "Andy Banwell" ( hidden link ) and it is now showing only the relevant records under the "Feature Films" (5) and "Commercials" (4), just as added in the admin area:
( screenshot: hidden link )

Your next reply will be private as well and I'll hold any further troubleshooting/testing until I'll receive the duplicator package from you. This way your actual production website won't be affected from any changes.