Create simple Joomla accordion using mootools


Sometimes you need accordion or slider tabs in a Joomla article. so you can divided paragraph to better understanding the topic for site visitor/reader. In Joomla you can easily create article accordion using mootools script.

First add following php code to template’s index.php file.

<?php
defined('_JEXEC') or die('Restricted access');
//Following code add Slide/toggle behavior to the theme
JHTML::_('behavior.framework',true);
$this->document->addScriptDeclaration('
window.addEvent("domready", function( ){
navAcc = new Accordion( $$( ".accordion .accT" ), $$( ".accordion .accE" ), {display: -1, alwaysHide: true} );
})');
?>

Your html code should looks as follows div structures.

<div class="accordion">
<h1>Creating Mootools accordion or simple slider</h1>
<a class="accT"><h1>Link 1 Container 1</h1></a>
<div class="accE">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<a class="accT"><h1>Link 2 Container 2</h1></a>
<div class="accE">
<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur in section 1.10.32.</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,  of Lorem Ipsum.</p>
</div>
<a class="accT"><h1>Link 3 Container 3</h1></a>
<div class="accE">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
</div>

That’s enough to working accordion in joomla. Refresh the site and open the article link where you add this above html. You can add css to beautify this accordion according to your theme.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s