Skip Navigation

[Resolved] Basic accordion implementation in Views (without shortcode)

This thread is resolved. Here is a description of the problem and solution.

Problem:
How can we properly add Accordions to Toolset Views Loops?

Solution:
https://toolset.com/forums/topic/basic-accordion-implementation-in-views-without-shortcode/#post-588751

This support ticket is created 6 years, 5 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 3 voices.

Last updated by Mark Sund 6 years, 5 months ago.

Assisted by: Beda.

Author
Posts
#588635

Tell us what you are trying to do?
Implement an accordion dynamically populated by a View, but without using an accordion shortcode plugin.
I have a View which retrieves entries from a particular CPT, and I want the results to form the content (i.e. panel headings and content) of an accordion structure. That is, I want the CPT 'title' value to populate the accordion panel heading, and I want the CPT 'excerpt' value to populate the accordion panel content.
I understand how to implement the jQuery code as long as I can either determine (or assign) the relevant id/class values to the accordion structure. However, I don't know the best way (or if it's even possible) for Views to generate the HTML code to support the accordion. My concern is that View may be generating HTML that is too complex to be used by the native jQuery accordion function.
For example, should the Views output (for each retrieved CPT entry) be unformatted? Bootstrap? Other?
How can the View results be wrapped in an appropriate container required to support the accordion function?

Is there any documentation that you are following?
Can't find any relevant items in the Toolset documentation.
Is there a similar example that we can see?
hidden link
What is the link to your site?

#588701

I was able to achieve my goal of generating a basic accordion structure using output from a View.
I will continue to experiment with additional accordion features and will advise of any issues.

Is there any reason that accordion functionality is not mentioned anywhere in the Toolset documentation?

That is, there have been other threads regarding accordion-based issues, so it's clear that they are being used.

#588751

We do not document this because it's a Bootstrap for even HTML feature, not a Toolset feature, and to use Toolset the HTML and CSS/JS languages are required knowledge sets.

What you will do to create your list of posts as accordions is:
- create your View as usual
- create a loop manually and insert the HTML markup you need to create the accordion.
==> Replace unique ID's with as example post ID ShortCode.
- Then insert the Toolset ShortCodes in the relevant HTML markup of the accordions body.

The loop will iterate over all posts and generate the same HTML output for each post.

The final Loop output should look something like this (made with a Bootstrap accordion)

<wpv-loop>
  <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapse-[wpv-post-id]" aria-expanded="false" aria-controls="collapse-[wpv-post-id]">
  [wpv-post-title]
  </a>

  <div class="collapse" id="collapse-[wpv-post-id]">
    <div class="well">
      [wpv-post-excerpt]
    </div>
  </div>
</wpv-loop>
#588754

Thanks.

#905242

Thank you – a big help!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.