开发者

expanding / collapsing FAQ

开发者 https://www.devze.com 2023-01-11 02:07 出处:网络
I need to add FAQ list to a page, and I would like to expand / collapse the answers when a question in the list is clicked.

I need to add FAQ list to a page, and I would like to expand / collapse the answers when a question in the list is clicked.

Could you suggest any Drupal module for doing this ?

If I'm not wrong, the FAQ module (http://drupal.org/project/faq) doesn't include t开发者_开发百科his feature (expanding/collapsing).

thanks


I've actually seen there is this option in FAQ module. In the description on Drupal website it was not clear...


Something like this, is most easily done in your theme. All you really need is a few lines of css and JavaScript. I doubt you will find any module that does this, since it will be very hard to make generic and user friendly while it's very easy to make it customized in your theme.


Have you considered using jQuery UI Accordion? You can just write out your FAQ as a standard list and apply the accordion effect to it in your theme.


Create a FAQ content type with title and description. Make a node-faq.tpl file in themes with following content.

<div id="accordion">
<h3><a href="#"><?php print $node->title ?><a></h3>
<div><?php print $node->content ?></div>
</div>

Make a javascript file acc.js with following content and add it into the theme folder.

jQuery(document).ready(function() {
  $('.accordion.head').click(function() {
    $(this).next().toggle();
    return false;
  }).next().hide();
});

Or animated:

jQuery(document).ready(function(){
  $('.accordion.head').click(function() {
    $(this).next().toggle('slow');
    return false;
  }).next().hide();
});

Include this file in theme.info

scripts[] = acc.js
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号