Zach Smith
Zach Smith

Reputation: 5674

Placing Different Modules Per Each Article in Joomla?

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.

Upvotes: 1

Views: 3274

Answers (3)

LearnIT
LearnIT

Reputation: 346

You said you can only place one module. Have you tried placing multiple modules in the same positions?

Let's say you want to put something in "position-3".

You are not limited to having one thing per position, you can place as many modules as you want into that position. After, you can also pick priority/order.

Hope this works for you too.

Upvotes: 0

Zach Smith
Zach Smith

Reputation: 5674

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.

Upvotes: 0

derekerdmann
derekerdmann

Reputation: 18252

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.

Upvotes: 1

Related Questions