Sauter la navigation

[Résolu] Style radio button output on the front end

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
The user wanted to style a view loop output based on a custom field value. He wanted to use different images based on the same custom field.

Solution:
Having a few possible values for the fields, a custom taxonomy with featured image field will be a good fit/solution for the use case.

Term fields(featured image) cannot be inserted inside a posts view. We'll need to use a taxonomy view inside to loop to display the term featured image.

Relevant Documentation:

This support ticket is created Il y a 5 années. 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: Africa/Casablanca (GMT+01:00)

Marqué : ,

Ce sujet contient 11 réponses, a 2 voix.

Dernière mise à jour par nicoleR-3 Il y a 5 années.

Assisté par: Jamal.

Auteur
Publications
#1600245
Screenshot_2020-04-24 Edit KWPN-NA Breeder ‹ KWPN-NA — WordPress.png
Screenshot_2020-04-24 KWPN-NA Breeders Directory - KWPN-NA.png

Tell us what you are trying to do?
I was wondering if there was a way to style each output for each corresponding radio button selection. Ideally, I'd like the each selection to have a corresponding color - gold, platinum, bronze, silver. Hopefully the attached images will demonstrate what I'd like to achieve.

Thank you.

Is there any documentation that you are following?
Searched documentation and the forums but couldn't find my specific issue.

Is there a similar example that we can see?

What is the link to your site?

#1600709

Hello and thank you for contacting the Toolset support.

You can display different styles/images using the conditional features of Toolset. If you are building your view with the Block Editor, you can use the conditional block. Check our youtube channel for some demos lien caché

If you are using shortcodes for your view, you can use the conditional shortcode or use the conditional button to build the conditions with the graphic interface.
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/

Let me know if you still need any information or if you want me to take a closer look at your views.

#1600833
Screenshot_2020-04-25 Edit Group ‹ KWPN-NA — WordPress.png

Thanks so much! I got that all figured out.

Is it also possible to configure the radio buttons so they output a particular image if selected? If this is possible, how would I set up the values for the field to produce an image as the output instead of text? See attached.

#1600865

No, It is not possible to have an image for a select custom field. You will have to manage the icon and values of the select in your templates or in your code.

Instead, I suggest using a taxonomy for "Beeder level" rather than a custom field. Taxonomy terms can have an image, then you can upload an image per Beeder level term. You can add fields to terms too and display them on the frontend:
- https://toolset.com/documentation/user-guides/custom-content/term-fields/
- https://toolset.com/documentation/user-guides/custom-content/displaying-wordpress-term-fields/

And you can use a plugin like this one to have only one term per post: https://wordpress.org/plugins/ps-taxonomy-expander/

#1601035
Screenshot_2020-04-25 Edit Term Field Group ‹ KWPN-NA — WordPress.png
Screenshot_2020-04-25 Edit View ‹ KWPN-NA — WordPress.png
Screenshot_2020-04-25 Edit View ‹ KWPN-NA — WordPress(1).png
Screenshot_2020-04-25 Edit View ‹ KWPN-NA — WordPress(2).png

Oh wow. This looks great. Unfortunately, I seem to be having an issue. I went and set up the term field group as described in the first link and added all the images for the categories, but I am not seeing the new field group when I try to add it to my view. Or is it there and I am completely blind? Screenshots attached.

#1601635

Thought I had it figured out, but did not.

#1603177

Hi, is there anyone out there to help me solve the issue I'm having with the term fields?

#1604175

Hello and my apologies for the late reply. I don't work on Sundays and Mondays.

Please check this article on how to display term fields: https://toolset.com/documentation/user-guides/custom-content/displaying-wordpress-term-fields/
You can also use a shortcode directly [types termmeta="term-test"][/types]
https://toolset.com/documentation/customizing-sites-using-php/functions/

If you are still unable to display the term image, please allow me temporary access to check it closely. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

I will need to know which view/template.

#1604585

I visited the following page and everything seems working.
lien caché

I am not sure to understand what is still blocking you? Can you provide more details? What have you done? Where are you stuck? What views? possibly screenshots.

#1604633
Screenshot_2020-04-28 Edit KWPN-NA Breeder ‹ KWPN-NA — WordPress.png
Screenshot_2020-04-28 Edit View ‹ KWPN-NA — WordPress.png

The icons are currently showing not because they are being drawn from the category image, but because I have a field in the custom post type where the image is uploaded. I love the idea of the user just clicking a category and having the image show up (or if they don't have a category, then the default image appearing automatically). Otherwise, they have to upload the an image each time they add a new entry. I'm hoping this can be controlled automatically so the user doesn't have to upload the image each time they add a new breeder. They can just add the details and contact information. See attached screen shots. I hope that makes sense.

#1605851

Ther term fields such as the level featured image cannot be displayed directly on a posts view. It needs to be displayed on a taxonomy view which has a term filter on the parent post. Then the taxonomy view can be used inside the posts view.

I made an example with the view "Breeders Level Featured Image" I'll let you check it further to see how this could be done.

#1606219

Oooooh. I see. And I get how to add the default icon if there is no category selected. This is fantastic! There is so much to learn about this plugin. Thank you so much for your help!!