startExpandCollapse with default content Open [Solved]

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
tophers
Forum Members
Forum Members
Posts: 218
Joined: Thu Jun 07, 2007 7:25 pm

startExpandCollapse with default content Open [Solved]

Post by tophers »

I hope I'm not posting about something that's already been answered, but I'm looking for a way to set a default open state to a div that's set to Expand/Collapse. I have 4 divs set up this way, and want the first to be open by default. Is there a way to trigger expandcontent('div1')?
Last edited by Anonymous on Mon Mar 01, 2010 11:46 pm, edited 1 time in total.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: startExpandCollapse with default content Open

Post by jmcgin51 »

I don't think startExpandCollapse offers this (at least not without some hacking), but I think firstExpandCollapse does.  It's in the plugins in the Forge.
User avatar
tophers
Forum Members
Forum Members
Posts: 218
Joined: Thu Jun 07, 2007 7:25 pm

Re: startExpandCollapse with default content Open

Post by tophers »

That sounds like a great solution. I can't seem to find the plugin on the Forge, though, just a few references in other postings. Without the actual plugin I'm not sure what parameters I can pass to it - do you have a link to the actual Plugin?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: startExpandCollapse with default content Open

Post by calguy1000 »

This stuff is so easy to do with jquery.... I would like to suggest that the expandcollapse stuff is redundant.

it'd be something like this (untested):

Code: Select all

<ul class="foo">
  <li>a</li>
  <li>b</li>
  <li>c</li>
</ul>

Code: Select all

// JQuery Code
jQuery(document).ready(function(){
  jQuery('ul.foo li').hide();   // hide all the items
  jQuery('ul.foo').children('li:first').show();  // show the first item
  jQuery('ul.foo li').click(function(e){
    // list item clicked
    jQuery('ul.foo li').hide();
    jQuery(this).show();
  });
});
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
tophers
Forum Members
Forum Members
Posts: 218
Joined: Thu Jun 07, 2007 7:25 pm

Re: startExpandCollapse with default content Open [Solved]

Post by tophers »

Thanks CalGuy - that's probably a better option, especially considering we already have a few jQuery calls. But in the meantime we (and by we I mean my developer Russ!) came up with this:

Code: Select all

	static $firstExpandCollapse = true;//only gets set one time per page
	
	global $gCms;
	$config =& $gCms->GetConfig();

	if (!empty($params['id']) && !empty($params['title'])) {
		$id = $params['id'];
		$title = $params['title'];
		$default = $params['default'];
	}
	else {
		echo 'Error: The expand/collapse plugin requires that both parameters (id,title) are used.';
		return;
	}

	if ($firstExpandCollapse) {
		echo '<__script__ type="text/javascript" language="javascript" src="'.$config['root_url'].'/lib/helparea.js"></__script>';
		$firstExpandCollapse = false;
	}
	$url = str_replace('&', '&',  $_SERVER['REQUEST_URI']);
	$result = '<a href="'. $url .'#'. $id .'" onclick="expandcontent(\''.$id.'\')" style="cursor:hand; cursor:pointer">'.$title.'</a><br />';
	$result .= (isset($params['default'])) ? '<div id="'.$id.'" style="display:block;">' : '<div id="'.$id.'" class="expand">' ;
	echo $result;
The $default parameter let's us set the start item - seems to be working! But I'll look at the jQuery route and see if it's a simpler solution.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: startExpandCollapse with default content Open [Solved]

Post by jmcgin51 »

you're right, sorry - it wasn't in the Forge...

it was in this post, which you probably already found

http://forum.cmsmadesimple.org/index.php?topic=16892.0

I was thinking of the StartExpand and StopExpand tags, which claim to enable expanded state on page load.  However, they do not appear to be functional, at least with current CMSms versions.

http://dev.cmsmadesimple.org/projects/stopexpand & http://dev.cmsmadesimple.org/projects/startexpand
Post Reply

Return to “Modules/Add-Ons”