I am trying to: to use a conditional output in an accordion. I have a custom post type which has a field (brand/services offered) which only applies when "type-of-organisation"=retail.
I have an accordion with various fields displayed (contact, map, brand,...). I only want to have the brand & services offered tab displayed when the organisation is retail as for other organisations this will be empty.
I've used the conditional output elsewhere but don't see how to use it in this case (not in the field but I don't want the tab/accordion to appear if it's empty).
So far I've kept it outside the accordion but it doesn't look as good.
Thanks!
Hi, it's not currently possible to wrap an entire panel in a conditional. Could I see the accordion on your site? I might be able to provide a workaround based on JavaScript and CSS. Please let me know where I could view it and I will take a look. Thanks!
Thanks Christian for your reply.
You can find my accordion at hidden link
The last 2 tabs are conditional (for them to appear, type-of-organisation needs to be "retail" and obviously the tab itself not empty).
Is it possible with CSS to have different colours for each header in the accordion? I'd like to have 6 headers in a gradation of a colour.
Thanks!
I would need to take a look at your wp-admin area as well, I need a bit more information. Can you provide login credentials for me in the private reply fields here? I won't make any changes yet, I will just investigate. Thanks!
Okay I'm confident I can get the last two accordion panels to disappear when the type of organization is "retail" and the panel is empty. I'll need to do the following things:
- Add unique CSS classes to each of the panel elements
- Add some JavaScript that tests the type of organization and shows or hides the appropriate panels
In order to apply different colors to each header, we can use those unique CSS classes. However, I'd rather handle that in a separate ticket since the solution is more complex than just a few sentences.
So if it's okay with you, I'll go ahead and add the CSS and JavaScript to this Layout. Then we can do a quick review. Let me know and I'll get started. Thanks!
Please go ahead! I'm looking forward to the results.
I've just added a second type-of-organisation (health) which can offer a "service", so (if that doesn't make it too hard), I would want :
for header "brand" to appear, the type of organisation needs to be "Retail" and the content of the field "not-empty"
for header "services offered" to appear, the type of organisation needs to be "retail" or "health" and the content of the field "not-empty".
Once I know the css classes for all tabs, I could add the css myself. I'll raise another ticket to find out how to differentiate the various CSS classes.
Thanks!
OK a bit of bad news - it's not possible to use WYSIWYG values in conditional clauses, unfortunately. So I can't include that part of the logic to show and hide the services offered panel. If you want to include a separate custom field that indicates whether or not to show the services panel, I can help you integrate that.
However, the rest of the logic has been implemented and is ready for you to review. You may use the following CSS selectors to target the toggle header elements:
.fusion-toggle-heading.toolset-accordion-panel-about-us
.fusion-toggle-icon-wrapper.toolset-accordion-panel-about-us
.fusion-toggle-heading.toolset-accordion-panel-how-to-contact-us
.fusion-toggle-icon-wrapper.toolset-accordion-panel-how-to-contact-us
.fusion-toggle-heading.toolset-accordion-panel-where-we-are
.fusion-toggle-icon-wrapper.toolset-accordion-panel-where-we-are
.fusion-toggle-heading.toolset-accordion-panel-map
.fusion-toggle-icon-wrapper.toolset-accordion-panel-map
.fusion-toggle-heading.toolset-accordion-panel-brands
.fusion-toggle-icon-wrapper.toolset-accordion-panel-brands
.fusion-toggle-heading.toolset-accordion-panel-service
.fusion-toggle-icon-wrapper.toolset-accordion-panel-service
You have separate selectors for the "+" icon and the text block.
Thanks, Christian.
This is perfect and great, you've been a great help!
I'll manage the css myself.