Views Accordion provides a display style plugin for the Views module.
It will take the results and display them as a JQuery accordion.

Installation

  1. Place the views_accordion module in your modules directory (usually under /sites/all/modules/).
  2. Go to /admin/build/modules, and activate the module (you will find it under the Views section).

Using Views Accordion module

See attached file for an example. Your view must meet the following requirements:

  • Row style must be set to Fields.
  • Provide at least two fields to show.

Choose jQuery UI accordion (or Views Accordion for D7) in the Style dialog within your view, which will prompt you to configure (D7 - Needs updating for D8):

  • Transition time: How fast you want the opening and closing of the sections to last for, in seconds.
    Default is half a second.
  • Start with the first row opened: Whether or not the first row of the view should start opened when the view is first shown.
    Uncheck this if you would like the accordion to start closed.
  • Use the module's default styling: If you disable this, the CSS file in the module's directory (views-accordion.css) will not be loaded. You can uncheck this if you plan on doing your own CSS styling. (Not supported in D7 yet)

IMPORTANT
The first field WILL be used as the header for each accordion section, all others will be displayed when the header is clicked. The module creates an accordion section per row of results from the view.

Theming information (Needs updating for D8)

This module comes with a default style, which you can disable in the options (see above). Files included for your convenience:

  • views-accordion.css - A default stylesheet with how the classes the author thought would be best used.
  • views-view-accordion.tpl.php - copy/paste into your theme directory - place the comments in this file for requirements/instructions.

Both files are commented to explain how things work. Do read them to speed things up.

Print Style

If your accordion includes important, printable information, you can force expand all views_accordion items in your print css (ex. print.css in zen theme) with the following, as a start:

.views-accordion-item .accordion-content {
  display: block !important;
}

IMPORTANT
Disable Theme Developer because it is incompatible and will corrupt the accordion rendering.

Accordion header

Grouping

When grouping fields, the group header can be used as accordion header by using the option
Use the group header as the Accordion header

Combined fields

Views allows for one field to include the content of multiple fields, so you can utilize this views feature for this purpose. See this screenshot for an example setup.

  1. Click on the field you want to, and check "Rewrite the output of this field" ... it will open a whole settings section for you.
  2. In there you can use the "Replacement patterns" which will allow you to use previously listed fields within that field. It also allows you to use html in there.
  3. Then check Exclude from display on the fields before that, since you are including them in that field already.

Comments

ricancie’s picture

Hello!

I am using views accordion and itworks fine. However, the text that appears does not appear with the text format, so colors, fonts, bullet points, paragraph and pictures that are in the article do not appear.

I have seen a lot of tutorials and it seems that the text format should appear. So I don't know what I am doing wrong and what setting is not correctly chosen. Can you please help me??

Thanks a lot!

phil.lizt’s picture

Hello!

I ran in the exact same problem lately. The html tags of the content fields were displayed in plain text in my accordion view. Switching the format of those fields to full html as seen in some forum posts did not work for me either so I figured it clearly should be connected to the view itself.

In my case I had the summary function of views turned on. After disabling that option it works perfectly even with filtered html format applied to the fields.

Kind Regards

swiatekt’s picture

I found this Views Accordion video tutorial on YouTube very helpful to get started with the module quickly.

http://youtu.be/bd6vNIyJJCE

BEGRAFX’s picture

I'm trying to add "Views Accordion" on my Drupal 8 project, but I'm hitting some snags, and all of the information I'm finding seems to be related to D7 (or even D6). Is there information somewhere, on getting this to work with Drupal 8?

Here's what I'm encountering:

I go to the STRUCTURE menu, and select VIEWS, and select "ADD VIEW". I enter my View name, in "View Settings" I choose to SHOW: Content of type Article tagged with [TAG], sorted by Newest First.

I will just need a page, so I check "Create a page" leaving "Create a block" unchecked.

Under "Page Settings", under "Display Format", I am not given a "Views Accordion" option, as the tutorial pages I've seen seem to indicate. Mine gives an option for, "jQuery UI accordion". I select that and I select "fields" I click "Save and Edit", and it takes me back to the top of the page, and I get an error which reads:

Setting "Row to display opened on start" to "None" requires "Collapsible" to be enabled.

The new view will not save, so I cannot go into it to change any settings. I've looked through all of my "Configuration" screen, and I see nothing that looks to be settings relating to this.

Help!

Manuel Garcia’s picture

This documentation is for 7.x. There isnt a documentation page specific for 8.x yet.

If you feel you need support configuring your site to use the module, please open a support request on the module's issue queue here: https://www.drupal.org/node/add/project-issue/views_accordion - perhaps it is a bug and others will be able to chip in and eventualy solve the problem.

d2d’s picture

If you click Settings next to JQuery UI accordion, there is a checkbox for collapsible and a setting for which, if any item in the eaccordion you want to open on access.

I hope this helps.

Now if someone will only tell me where the setting that controls the header color is, I will be in good shape.

lharley’s picture

I am working with Drupal 8 and trying to use Views Accordion, but I couldn't get passed creating a View as described in the Drupal 7 tutorials. I kept getting the 'Collapsible' error so the View was never created. The workaround I managed was to create a View using any content and HTML format style EXCEPT jQuery Accordion. Once I created the Accordion View, I was then able to go into the Edit page and change the View format and style to jQuery Accordion. I then got the same error as before, but this time I could select the jQuery Accordion settings and set the options as required (which are shown in the Drupal 7 tutorials). Hope this helps someone else.

jadiaz’s picture

para los compañero que no han podido hacer uso de Views acordeon en drupal 8 , le sugiero que al crear la vista no seleccione el formato Acordeón, seleccione cualquier otro formato y luego lo cambia y de seguro le funcionará

jadiaz’s picture

He intentado implementar View Acordeón en drupal 8, pero solo me funciona en la previsualización de la vista y en el tema base del core drupal si alguien lo logro implementar en el tema principal me sería de mucha ayuda