By juc1 on
Hi all,
I am trying to get text (for a View) which starts collapsed / hidden but which displays after clicking on 'more details', something like this...
http://tinyurl.com/7qz6z5s
I followed the instructions here
http://willhallonline.co.uk/blog/collapsible-fieldsets-drupal-7-nodes
I amended the bottom of my template.php =
http://jarabic.co.uk/templatephp.txt
my html = http://jarabic.co.uk/html2.jpg
result = http://jarabic.co.uk/legend
Can anyone please suggest how I can get the text to start off hidden / collapsed ie requring a click to display?
Thank you
Comments
It may not be exactly what
It may not be exactly what you want but maybe look at Views Accordion?
http://drupal.org/project/views_accordion
Ok thanks I will take a look
Ok thanks I will take a look but anyway what I am trying to do is something like this where it says 'more details'
http://tinyurl.com/7qz6z5s
thanks
i had a similar problem, i
i had a similar problem,
i did try a module called 'collapse text' but this broke my website (so try at own risk and make sure the website is backed up).
I did find two java scripts that might help - the first one is similar to the more details on the lipsdoctor website
I can't find the actual HTML & CSS that goes with this one, sorry.
And the second one that i am currently using is an accordion effect
CSS
and the JS
and the html would be
I managed to use the text editor and have this effect appear as my content in the center of the page, hope some of that helps, any questions please ask.
Collapsed
Collapse Text module doesnt seem to work, so I wouldn't bother.
basically just add "collapsed" into the fieldset class to make it start collapsed
@ willhallonlineYes that
@ willhallonline
Yes that works, thanks for your help. I tried the collapse text module already but it didn't seem to work for me.
Can I please ask about your code comment:
'This function looks for node 1 and only adds the javascript for this. However it can be extended in different ways if required.'
Is there some restriction on where your code will work? I have tried it in different nodes without amending template.php and it seems to work fine.
Thanks
If statement
What I was meaning by "This function looks for node 1 and only adds the javascript for this. However it can be extended in different ways if required." is that the statement looks for the node_id and if it is number 1 then it enables the javascript and such like. However, you could adjust the if statement to give a multitude of results (selecting on user/theme/node type etc).
You could remove the if statement if it is being used on every page of the site (in a block or such like) but I thought it was better to restrict to just the certain nodes that it was applicable to.
Hope that helps.
Collapse Field Requires Collapse JS
Hi folks, I had a lot of trouble with my collapse fields also.
I was trying to use collapse on a page that did not have a form.
If you are doing it on a form, form.js may already be included.
It seems there are two main parts:
Once you have used the proper code to invoke the collapse box:
You can specify a condition in preprocess to add these files on a particular page.
Here's what I did to include them on every page of my website. This is not the best method, but it worked for me.
I had the most trouble with getting the js to appear. Even after I had invoked drupal_add_js in many places, it was not working for me until I added it specifically in the template.php document under function THEMENAME_preprocess_html
THEN I was able to see that collapse.js was being added to the HEAD section of my page.
IF collapse.js IS NOT in the HEAD section of your page, then collapse will never work.
Goodluck.
P.S. if you want to start with the box closed, just include the class: collapsed in the html