Skip Navigation

[Closed] toolset template, custom field checkbox in custom post displays icon

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 9 replies, has 2 voices.

Last updated by Minesh 1 year, 10 months ago.

Assisted by: Minesh.

Author
Posts
#2365459

I have a custom post type accommodation (hbook plugin)
I have a toolset template for that custom post type

I have a custom field set of checkboxes displayed in the custom post type which lists room amenities.
I would like each one that is checked to cause an icon to display on the front end
I can not just put the icons in the template as rooms feature some amenities and not others

For example my client checks Air con, Safe, Shower. The 3 icons for those things appear on the front end and not those for the unchecked items.

Can I do this? Is my approach wrong?
Is there any documentation to explain?

The result would look like this hidden link

#2365627

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please tell me the checkboxes field you are talking about is it created using Types?

#2366259

Yes I have created a multiple checkbox custom field with toolset and it appears in the custom post type accommodation.
Accommodation post type has a toolset template assigned.

Not sure if this is even the right approach.
I just want a way for the user to say that selected svg icons should appear for a particular accommodation post.

#2367557

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

There are two ways to check if the checkboxes option is checked or not.

Using Types field:

[types field="your-field-slug" option="0" state="checked"]
// add something to display when checkbox option 0 is checked
[/types]
[types field="your-field-slug" option="1" state="checked"]
// add something to display when checkbox option 1 is checked
[/types]
[types field="your-field-slug" option="2" state="checked"]
// add something to display when checkbox option 2 is checked
[/types]

Another way is using [wpv-conditional] shrotcode:

[wpv-conditional if="( '[types field="your-field-slug" option="0"][/types]'  eq 'option_value' )"]
Content
[/wpv-conditional]
 
[wpv-conditional if="( '[types field="your-field-slug" option="1"][/types]' eq 'option_value' )"]
Content
[/wpv-conditional]

Where:
- Replace option_value with your original checkboxes option value.

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/
- https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes

#2368155

Hi,
I am looking into that. But let's just forget all about the checkboxes for a while.

I am using Kadence pro theme and blocks and toolset.
If I have accommodation post type.
A toolset template for that post type built with blocks.
I can not put the svg icons in the template because each accommodation post needs to show only a subset of the icons on the front end.
Somehow I must be able to have the post type communicate to the template what icons to show.
What would be the best way?
The svg icons are displayed by a block.
Could I have the icons in the custom post type and pull them into the template?
Just looking for the right way to do this.

#2369085

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please tell me where you stored your icons? You uploaded it to media library?

#2369511

Hi,
I am not currently uploading the svg files to my media library. If that is possible I would be willing to if it would help.
Currently I use "The Icon Block" which allows me to paste the actual svg code into the block, then has some simple styling controls.
I use it this way on basic pages. I am not sure it can be used for my problem in a template.
https://wordpress.org/plugins/icon-block/

I am open to any solution that works.

The block does allow me to add a class like most gutenburg blocks in the advanced section. If that helps.
Is there a way I could set the blocks individually to display:none using toolset. I could have all of the icons in the template and turn some off?
Just trying to have some ideas!

#2369817

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As you are using blocks, have you tried the conditional block?
=> https://toolset.com/course-lesson/using-toolset-conditional-block/

So, what if you add a conditional block and setup the conditional statement using block. If you can able to share admin access details and share where you want to display what icon based on what checkbox option then I can review the setup and able to guide you in right direction.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2374791

Hi,
I am on vacation so did not set up a page for you to try. I did try the conditional block.
I got it to work by making a custom field single check box for each item.
I could not get it to work with a multiple checkbox custom field Amenities. I tried setting the check boxes to return a unique static value such as 'bath' or 'tv' When I tried this it did not work although debug seemed to say my value was being returned.
I am fine as it is, but it would be neater to have 1 multiple checkbox custom field. Is there a way to make that work?

#2374917

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - we do have way to check conditionals for both single checkbox field and multiple checkboxes field.

Once you get back from your vacation, please let me know and share the access details with test page and I'm happy to guide you in the right direction.

The topic ‘[Closed] toolset template, custom field checkbox in custom post displays icon’ is closed to new replies.