WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Two different layouts
  • Print
Pages: [1]   Go Down

Author Topic: Two different layouts  (Read 3662 times)

Kolb

  • Guest
Two different layouts
« on: December 18, 2009, 12:28:24 AM »
Hello,

I just managed to port a design to WB. And everything seems to work fine!

This website in particular has a homepage were I divide the content in 3 columns (welcome/what to do/promotion). I manage to do this with blocks.

But when you visit another page (products/contact/etc) I would like to display my content in one column instead of 3 columns. How would I go about that? Do I just use a different template for the homepage, or is there a specific trick?

Thanks
Logged

Offline BerndJM

  • Posts: 1764
  • Gender: Male
Re: Two different layouts
« Reply #1 on: December 18, 2009, 03:05:29 AM »
Hi,

if you only need this specific 3-column template one one (or few) page(s) the easiset way would be to use another template for the remaining sites.

Regards Bernd
Logged
In theory, there is no difference between theory and practice. But, in practice, there is.

Offline marathoner

  • Posts: 495
Re: Two different layouts
« Reply #2 on: December 18, 2009, 03:35:23 AM »
Another option is to modify your template such that if page_id=1 (home page) then use 3 column otherwise use your 1 column format. Or, you could test a page to see how many section block and then use the appropriate format for that many section blocks. This approach allows you to maintain a single (but slightly more complex) template.

As an example, I sometimes use the following to switch from 1 column to 2 column (but there are probably better ways to write the code):

Code: [Select]
<div id="content">
<?php
    ob_start
(); // Start the outputbuffer
    
page_content(2); // Next call the block
    
$content2=ob_get_contents();  // Now fetch the output into a variable
    
ob_end_clean(); // Clean up old mess and stop buffering

    // Test $content2 to see if there is something in it. If so, include column wrappers for content1 and content2.
if ($content2<>"") {
    echo 
"<div id=\"content1\">\n";
    
page_content(1);
    echo 
"\n</div><!-- close div#content1 -->\n";
    echo 
"<div id=\"content2\">\n";
    echo 
$content2;
    echo 
"\n</div><!-- close div#content2 -->\n";
    }
else { 
// Otherwise, just output content1
    
page_content(1);
    }
?>

</div><!-- close div#content -->
« Last Edit: December 18, 2009, 03:39:38 AM by marathoner »
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Two different layouts
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2