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

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
fredd
New Member
New Member
Posts: 6
Joined: Tue Sep 16, 2008 7:39 am

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

Post 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.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

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

Post by jmcgin51 »

thanks fredd

Moderator move to Tips/Tricks?
fredd
New Member
New Member
Posts: 6
Joined: Tue Sep 16, 2008 7:39 am

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

Post by fredd »

Just curious, do you think people use this? Should I submit more jQuery tips?
viebig

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

Post by viebig »

please, go to tip's and tricks and make our community happy adding a few tips like that

Regards

G
Post Reply

Return to “Tips and Tricks”