0

I've created a Joomla template (3.2). and my each page type has different class like, All article pages have article class, and contact us page have contact-us class

<!--For About us page -->
<div class='container article'>
...
</div>

<!--For Contact us page -->
<div class='container contact-us'>
...
</div>

and so on.. so is there any way to get this thing done ?

I am not preferring to create a template for each page..

kamal pal
  • 4,187
  • 5
  • 25
  • 40
  • Take a look at the php code [here](http://stackoverflow.com/a/10777948). I think it might be useful – HamZa Mar 04 '14 at 07:51

3 Answers3

0

You could get part of the url and if it contains some specific words, you can make an if () else (if ()else()) printing those divs or a case if you want more options

0

If you want to specifically identify a page type, you'll need to know the component and the view being displayed. If you're in the template file, you can get these like this:

$input = JFactory::getApplication()->input;
$component = $input->get('option');
$view = $input->get('view');

These are just strings so using them as a class is as simple as something like this:

<div class="container <?php echo $component, '-', $view; ?>" >...</div>

Which should give you something like this:

<div class="container com_content-article" >...</div>

When the page is an article view of the com_content component.

Okonomiyaki3000
  • 3,628
  • 23
  • 23
0

First set class name in one variable using different condition and then append this value in class attribute. like following:

<?php

$input = JFactory::getApplication()->input;

$view = $input->get('view'); 

$container_class=$view;

// also add more condition and set $container_class


?>
<!--For About us page -->
<div class='container <?php echo $container_class; ?>'>
    ...
</div>