Reputation: 897
I am new to Joomla and have been asked to convert a non-Joomla site to use Joomla.
The site has a structure similar to an accordion menu, where the page content appears under the link to the page, like this:
Clicking on Article 1 Link:
╔════════════════╦══════════════════════╗
║ Article 1 Link ║ ║
║ ║ Content of article 1 ║
║ Article 2 Link ║ ║
║ Article 3 Link ║ ║
║ Article 4 Link ║ ║
║ Article 5 Link ║ ║
╚════════════════╩══════════════════════╝
Clicking on Article 3 Link:
╔════════════════╦══════════════════════╗
║ Article 1 Link ║ ║
║ Article 2 Link ║ ║
║ Article 3 Link ║ ║
║ ║ Content of article 3 ║
║ Article 4 Link ║ ║
║ Article 5 Link ║ ║
╚════════════════╩══════════════════════╝
Is it possible to do this in Joomla 2.5? I am struggling to understand how, since you can have a menu module, but how would you display article content within that module?
The article content will ideally be within the same <li>
of the menu item, so in html view:
<ul>
<li><a href="#link1">Link 1</a></li>
<li class="current"><a href="#link2">Link 2</a>
<div>
<!-- ARTICLE CONTENT FOR Link 2 -->
</div>
</li>
<li><a href="#link3">Link 3</a></li>
</ul>
Upvotes: 0
Views: 584
Reputation: 897
I added a mod_menu override by copying the mod_menu file to MYTEMPLATE/html/mod_menu/CUSTOMMENUNAME.php
I then added in this to the for loop:
if ($item->id == $active_id) {
Which allowed me to see which page was currently being viewed. The with the great help of rcarey over on The Joomla! Forum, I added this to the top of the mod_menu file:
require_once JPATH_SITE.'/components/com_content/helpers/route.php';
JModelLegacy::addIncludePath(JPATH_SITE.'/components/com_content/models', 'ContentModel');
// Get an instance of the model for getting an article
$model = JModelLegacy::getInstance('Article', 'ContentModel', array('ignore_request' => true));
// Set application parameters in model
$app = JFactory::getApplication();
$appParams = $app->getParams();
$model->setState('params', $appParams);
Then within the mod_menu loop, all I had to do was:
$article = $model->getItem($item->id)
Now I can use $article
within the loop in mod_menu.
Upvotes: 0
Reputation: 41
There is an example in components/com_contact/contact/tmpl/default.php that begins around line 50 (give or take) that shows how to use the built in JHtml accordion (called Sliders in Joomla). You could use that code as an example if you want to build a new module from a copy of mod_menu.
First, though, I'd recommend trying out a few extensions since there are a number of Accordion Menus available on JED. If nothing else, you'll get ideas on how best to implement. http://extensions.joomla.org/extensions/structure-a-navigation/menu-systems/accordion-menus
Upvotes: 2