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?
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" /> </div> <?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')): ?>
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.