T
T
Tlegen Bayangali2018-07-25 11:48:43
Joomla
Tlegen Bayangali, 2018-07-25 11:48:43

How to create a separate layout for secondary pages in Joomla 3?

The task is to create a separate layout for displaying content. The idea is that the main page does not have a sidebar, but the secondary ones should have one.
For example, I want the layout on the main page to be like this:

<div class="header">
  HEADER
</div>
<div class="row">
  <div class="col-md-12">
    CONTENT
  </div>
</div>

But on the secondary pages it was like this:
<div class="header">
  HEADER
</div>
<div class="row">
  <div class="col-md-3">
    SIDEBAR
  </div>
  <div class="col-md-9">
    CONTENT
  </div>
</div>

Creating another template and installing it on the CMS as a separate template is a clumsy method that will only load the site system once again, but a more delicate solution would be found. Maybe it's in the redefinitions? I looked through it, but I did not find anything similar to the layout. On some templates (not mine), I saw that when creating a menu item, it was also possible to choose among several layouts of the same style. Thank you in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tlegen Bayangali, 2018-07-25
@TlegenBayangali

In general, I found the answer for myself: if it is necessary to separate the layout of the main page (for example, the main page we have is a long landing page, and the secondary ones come with a sidebar), then you need to write a small php-construct in the index.php file located at the root of the folder template to define the main page.

<?php $myVar = $_SERVER['REQUEST_URI'];
if ($myVar == '/' or $myVar=='/index.php') {?>
<div>Its mainpage</div>
<?php } else {?>
<div>its secondpage</div>
<?php } ?>

Just instead of div blocks, you can include or request files with markup of the desired layout.
If there are any even simpler methods, then please, I will wait for answers!

A
Alex Fastovets, 2018-08-01
@Chiperok

What is wrong with the usual output of modules?
just then you choose that everywhere except the main one and that's it

<?php 
if ($this->countModules('position-1')) : ?>
<jdoc:include type="modules" name="position-1" style="none" />
<?php endif; ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question