Page 1 of 1

How to make comment forms slide in, and out for that matter..

Posted: Thu May 07, 2009 9:40 am
by fredd
First make sure you have jQuery in the head section.
For example like this:

Code: Select all

<__script__ type="text/javascript" src="uploads/jquery.js"></__script>
Then find the file:
./plugins/function.startExpandCollapse.php

You will have to make som changes here to make it work, replace the function smarty_cms_function_startExpandCollapse with this code.

Code: Select all

function smarty_cms_function_startExpandCollapse($params, &$smarty) {
	global $gCms;
	$config =& $gCms->GetConfig();
	if (!empty($params['id']) && !empty($params['title'])) {
		$id = $params['id'];
		$title = $params['title'];
	} else {
		echo 'Error: The expand/collapse plugin requires that both parameters (id,title) are used.';
		return;
	}
	echo '<span class="expander">'.$title.'</span>';
	echo '<div id="'.$id.'" class="expand">';
}
Next step is to write the code that makes the magic happen.
In the head section add this code:

Code: Select all

<__script__ type='text/javascript'>
{literal}
$(document).ready(function(){
	// Just to be sure, hide the forms.
	$(".expand").hide();
	$("span.expander").toggle(
		function () {
			$(this).next().slideDown("slow");
		},
		function () {
			$(this).next().slideUp("slow");
		}
	);
});
{/literal}
</__script>
And voila, you are all set. Hopefully someone will have some use of this.

Re: How to make comment forms slide in, and out for that matter..

Posted: Thu May 07, 2009 5:28 pm
by jmcgin51
thanks fredd

Moderator move to Tips/Tricks?

Re: How to make comment forms slide in, and out for that matter..

Posted: Fri May 08, 2009 6:27 am
by fredd
Just curious, do you think people use this? Should I submit more jQuery tips?

Re: How to make comment forms slide in, and out for that matter..

Posted: Fri May 08, 2009 7:56 am
by viebig
please, go to tip's and tricks and make our community happy adding a few tips like that

Regards

G