tags:

views:

408

answers:

2

I have a site with 10 articles. The layout of the site calls for a new sidebar on the left to be on every article. Easy enough, until I realize in my template file I can only call one specific module. Is there an easy way to have different modules per each article?

Easiest would be to have an if/else and show a different module depending on the article itself, but I don't know how to call the article in the following php:

<?php if( JRequest::getVar( 'view' ) == 'ARTICLE ID???' ): ?>
    <jdoc:include type="modules" name="your_custom_position" />
<?php elseif( JRequest::getVar('view') == 'ANOTHER ARTICLE ID????): ?>
    <jdoc:include type="modules" name="another article position" />
<?php endif; ?>
<?php endelseif; ?>

Any help would be appreciated in figuring this out.

A: 

You can put multiple modules in a single module position and still have them show up on different pages.

I'm assuming you're using Joomla 1.6.x. Go to Extensions -> Module Manager and then edit one of the modules for one of your pages. Under the "Menu Assignment" heading, select the "Select Menu Item(s) from the List" radio button and then click on the menu item for the page that you want the module to display on in the "Menu Selection" box. Now the module will be hidden until you go to that page.

Just repeat this process until you've set all your modules, and you're all set! If you decide you want one module to appear on multiple pages, just hold Ctrl and then select all the pages you want in the "Menu Selection" box.

derekerdmann
I want to use XXX Module Position, and have 10 different modules show in this same position throughout the site. Does your above example still do this for me?
HollerTrain
Yep. You could put any number of modules in any position. Just set the ordering in the Module Manager and you're all set.
derekerdmann
A: 

You would use this code:

<?php if( JRequest::getVar( 'view' ) == 'article' ): ?>
    <jdoc:include type="modules" name="article_sidebar" />
    <?php else : ?>
        <jdoc:include type="modules" name="landing_left_col" />
<?php endif; ?>

Works perfect, and you can show your PHP skills off to impress the females.

HollerTrain