Skip Navigation

[Resolved] render custom field checkbox selection on page php or similar template

This support ticket is created 4 years, 2 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
- 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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by chrisT-20 4 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1865231

Hi,

I am rendering icons based on whether site admin has ticked a series of boxes - it's a custom field of Checkboxes.

I have successfully rendered these on a custom post type created by Toolset (available experiences) using the types shortcodes:

<div class="row">

<div class="vc_col-sm-12 icon-payment-types-container">

[types field='payment-options' state="checked" option="0"]
hidden link">
<img id="chsp" src="hidden link" onmouseover="changeText('Commonwealth Home Support Program', '5px')" onmouseout="defaultText()" />

[/types]

[types field='payment-options' state="checked" option="1"]
hidden link">
<img id="ndis" src="hidden link" onmouseover="changeText('National Disability Insurance Scheme', '65px')" onmouseout="defaultText()" />

[/types]

[types field='payment-options' state="checked" option="2"]
<img id="dva" src="hidden link" onmouseover="changeText('Eligible DVA Card', '125px')" onmouseout="defaultText()"/>
[/types]

[types field='payment-options' state="checked" option="3"]
<img id="ph" src="hidden link" onmouseover="changeText('Private Health Refund Available', '185px')" onmouseout="defaultText()"/>
[/types]

[types field='payment-options' state="checked" option="4"]<img id="hcp" src="hidden link" onmouseover="changeText('Home Care Package', '245px')" onmouseout="defaultText()" />[/types]

[types field='payment-options' state="checked" option="5"]<img id="cf" src="hidden link" onmouseover="changeText('Customer Funded (Private Payment)', '305px')" onmouseout="defaultText()" />[/types]

[types field='payment-options' state="checked" option="6"]<img src="hidden link" onmouseover="changeText('Medicare Bulk Billing Available', '365px')" onmouseout="defaultText()" />[/types]

</div>
</div>

The issue is that the client want to render these on regular pages as well, so I need to add this logic to a new template I am creating - page-costicons.php. What is the php equivalent to the types conditional shortcode , something like:

IF (payment-options option 5 is checked ){

render image

}

#1865419

Hello,

You don't need to setup complicated custom codes for it, you just need to display that content template with Views PHP function render_view_template(), see our document:
https://toolset.com/documentation/programmer-reference/views-api/#render_view_template
Returns the content of a Content Template applied to a post.

It should be able to save a lots of time

#1866705

Hi Luo,

Thanks for getting back to me so quickly. I'm not sure that will work as I do not have a view set up for this custom field - I just pull this in via the code above into a view created by toolset (template for a custom post created by toolset).

But I also need to display conditional content based on the checkboxes in the custom field in regular pages - and I can't use a toolset template to display the regular pages - I need to use the PHP template.

Can I just create a view in toolset using the code above? then pull it into a PHP template using render_view_template() ??? When I go to create a view it prompts me as to what type of content I want to loop through which is not relevant in this case. If I can create a view and just paste the code above and then use render_view_template() then that is exactly what I will do but not sure it will work. Does that make sense? I can provide log in details if you need further clarification.

Chris

#1867373

In your case, it does not need view, let me describe the steps in details:
1) Create a content template, put the codes you mentioned above into the content
2) In your PHP template, use the render_view_template() function to display above content template.

If you want to display a Toolset Views with PHP codes, you can try another function render_view(), see the same document I mentioned above:
https://toolset.com/documentation/programmer-reference/views-api/#render_view_template

#1867407

My issue is resolved now. Thank you!