Different page templates for pages

by Vitalii   Last Updated April 23, 2015 21:04 PM

I need to create 2 templates for pages: "with sidebar" and "without sidebar".

I need to show sidebar for certain pages and hide it for others. This behavior should be configured thru options and not thru code.

How can I make it in Joomla 3.4.1?

Answers 2

Quite a simple thing to do. In your template's index.php add the following and change position-8 to whatever position in the sidebar.

<?php if ($this->countModules('position-8')) : ?>
    <div id="sidebar">
        <jdoc:include type="modules" name="position-8" style="xhtml" />
<?php endif; ?>

Basically, what this does is, it detects if there are any modules assigned to position-8 and will display the sidebar only if there are.

You may have multiple positions inside the sidebar, so you can also use:

<?php if ($this->countModules('position-8') && $this->countModules('position-9')): ?>
April 23, 2015 14:34 PM

I suggest to duplicate your template from Template Manager and do the modifications (no sidebar) to the new one without messing with the original one.

Then go to your menu and edit the menu item of your choice by selecting from "Template Style" list the duplicated (no sidebar) template.

April 24, 2015 17:01 PM

Related Questions

Create a custom user field for registration part

Updated November 10, 2017 15:10 PM

Hiding created date not working

Updated December 05, 2017 21:10 PM