Quote:
Originally Posted by cellarius
The element has to have an id that needs to be unique not only on the page, but on the whole site.
|
Yes, big truth: the collapsible element has to have a unique id.
I was trying to make all my static-html cms widgets collapsible. The problem was that that template is for all static-html cms widgets, so when assign a unique id in
HTML Code:
<a class="collapse" id="collapse_uniqueid"....
the results were a bit crazy, as cellarius said. Obviusly, if I put a text string for the id like above ("collapse_uniqueid"), that id string will be the same for all html-static widgets the page contains; so click on a widget collapses another, collapse buttons dissapear...
The solution was to make use of the widget's title as the unique id:
HTML Code:
<a class="collapse" id="collapse_{vb:raw widget_title}"....
So I change the
vbcms_widget_static_page template a bit:
HTML Code:
<div class="cms_widget collapse">
<div class="block">
<div class="cms_widget_header">
<a class="collapse" id="collapse_{vb:raw widget_title}" style="position: static" href="{vb:raw relpath}#top"><img src="{vb:stylevar imgdir_button}/collapse_40b.png" alt="" border="0" /></a>
<h3>{vb:raw widget_title}</h3>
</div>
<div class="cms_widget_content" id="{vb:raw widget_title}">
{vb:raw static_html}
</div>
</div>
</div>
Now every html-static widget has a unique id as each of them has an only one name, and probably all my widgets will be collapsible.
And all that thanks to
cellarius :up: