Author Topic: Different page layouts in one template  (Read 6416 times)

Offline mikejd

  • Posts: 225
Different page layouts in one template
« on: June 17, 2014, 10:42:13 AM »
I don't know if this is possible - to have a number of different page layouts within one template. For example, single column or two column. I have done this on one or two sites but by using more than one template. Each template is more or less identical just with a different page layout. One template is set as default and the other can be selected for any page as required.

I am happy to carry on doing this but it does seem unnecessary to have to upload all the files for each layout every time.


Offline Re-Mi

  • Posts: 97
Re: Different page layouts in one template
« Reply #1 on: June 19, 2014, 05:59:14 PM »

This is possible (maybe in other ways ) but i use the a little trick i read somewhere here on the forum.

between the head tags i will place as many from these codes as i need

   <?php ob_start(); page_content(1); $content1=ob_get_contents(); ob_end_clean(); ?>
   <?php ob_start(); page_content(2); $content2=ob_get_contents(); ob_end_clean(); ?>

They will have to correspond with the content tags in the info.php for example:

in info.php

Code: [Select]
$block[1] = 'main content full with';
 $block[2] = 'main content half with';

in index.php

between the head tags:

Code: [Select]
<?php ob_start(); page_content(1); $content1=ob_get_contents(); ob_end_clean(); ?>
<?php ob_start(); page_content(2); $content2=ob_get_contents(); ob_end_clean(); ?>

And at the place you need it:

Code: [Select]
<?php if(($content2) == true){ ?>
<div class="main half">
<div class="main full">
<?php ?>
<?php page_content(1); ?>
<?php if(($content2) == true){ ?>
<div class="main half last">
  <?php page_content(2); ?>
<?php ?>

and in the template.css you define the classes :

Code: [Select]
background: #FF00FF;
height: 500px;

.full {
width: 680px;

width: 335px;
float: left;

margin-left: 10px;

I think this should work, i did similar things with webpages i made, the above code i wrote as an example (and i think its correct, just try it) .

You should only change the blocks when you make the pages in the admin

p.s. don't judge my code  he he he i know i'm not a pro just trying to help out.