Drupal 7 Collapsing Fieldsets

morgawrus's picture

Good afternoon, guys,

I'm having a few little problems with a new drupal 7.2 site I'm currently creating, and I was just hoping someone may be able to help me. What's more frustrating is that my problem has arisen from purely aesthetic design choices.

In the Drupal Administration pages, mainly the modules page, all the fieldsets are collapsible and I am trying to achieve this same result on certain areas of my (basic) pages. The html I thought I could use was:

<code>

<fieldset class="collapsible">

<legend> Click Here to Collapse/Expand </legend>

<div class="fieldset-wrapper">

<p>

This is the text info</p>

</div>

</fieldset>

</code>

 

Now on the above code, the "Click Here to Collapse/Expand" does not act like a link, and is in fact plaintext. 

After a little investigation I noticed that the JavaScript file collapse.js was not included on my basic pages so I also included (after some searching on the Drupal.org forums):

<code>

<?php

drupal_add_js('http://mysite/misc/collapse.js');

?>

</code>

This still doesn't work.

I also tried a bazillion (hyperbole) different combinanations of the above pieces of code, including things like "drupal_add_library('file', 'drupal.collapse');" and even stealing the html straight from the module page source. 

At this point, I thought it might be something to do with my theme, blogbuzz, as the administration theme is set on the default Seven. So I changed the theme of my entire site to Seven and still could not get it to work. 

Now I'm thinking that it's just probably not as easy as I originally hoped and I have to do something a little bit....technical, to get it to work. I'm not a complete dunce when it comes to programming, but my php is sketchy at best (I really should learn it properly one of these days).

To verify my theory I just copied an entire page (with working collapsible filedsets) and posted them in a basic page. The collapsible menus don't work (so it's got to be something back-end?) and the links (<a href="#">) just reset the page view back to the top. 

Does anyone know of a solution to my problem (or even know what I'm talking about)?

morgawrus's picture

It also appears I can't use

It also appears I can't use HTML in the forum either Cry.

 

How embarassing.

 

Thanks in advance,

John.

morgawrus's picture

Sorted

Ok, sorted it out......in the least technical way possible.

 

http://drupal.org/project/collapse_text

 

Awesome project that lets you use [collapse][/collapse] tags to collapse sections of information. It does exactly what I was trying to achieve. Very easy to install and implement.

 

Cheers.

 

John x

greenavus's picture

cant get mine to work

I was having the exact same problem that you had and i stumbled upon this post. I am now trying to use the collapsed module but for some reason, mine is not working. This is what i have in my views global custom text

<div class="team_title">
[title] / [field_job_title]
</div>

<div class="team-body">
          [body]
</div>

[collapsed title=Read more..."]
         <div> [field_body_more]</div>

[/collapsed]


<div class="clear"></div>

I don't know what i am doing wrong. SO please can you look at the code and tell me what the problem is?

morgawrus's picture

Hopeful Help

With regards to the Collapsible field module. Have you configured your text formats to use the collapsible field filter? There are only certain orders that the collapsible filter can be processed in, i.e it must come after the "Convert line breaks into HTML".

I'm not making myself very clear, but, under your drupal Configuration>Content Authoring>Text Formats you can configure your allowed input types and you have to enable the collapsible text blocks and the Filter Processing Order.

 

Also, another issue with the module is that you can't have a [collapse] tag nested in a <div> or <span>, however you can nest [collapse] tags in [collapse] tags and you can have html tags nested inside your [collapse] tag.

 

I don't know how much help this is, I'll try and help further if this has been of no use.

 

Regards,

 

John

I got this working by

I got this working by using 

drupal_add_js('/misc/collapse.js');

In my template.php 

I did a write up on getting

I did a write up on getting this working through your template.php file and the requirements for Drupal 7. It took me about 4 hours to actually get it working properly, suffice to say all the info should get you up and running with collapsible fieldsets.

http://willhallonline.co.uk/blog/collapsible-fieldsets-drupal-7-nodes

collapse text

Hi all,

could anyone please take a look at my collapse text module question here.

@ willhallonline, sorry for being thick but is your write up nothing to do with the collapse text module ie is an alternative method? 

"This function looks for node 1 and only adds the javascript for this"

So it only works for node 1? Any suggestions please for how to remove this restriction?

Thank you

update -willhallonline's

update -

willhallonline's instructions work for me here

http://jarabic.co.uk/legend

but can I get the text to start collapsed rather than start uncollapsed?

 

Thank you