Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 06:10:06 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155555 Posts in 21715 Topics by 7737 Members
Latest Member: gx-world
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Multiple Content Blocks  (Read 1002 times)
rdsaunders

Offline Offline

Posts: 3


« on: January 16, 2008, 09:29:08 AM »

Hi There,

I've read http://help.websitebaker.org/pages/en/advanced-docu/designer-guide/content-blocks.php and I've been able to create multiple content blocks within my template and edit their content independantly. I've been unable to find the answer to my question on this forum or through our friend google.

I have attached a drawing of my requirement. The top section of the attachment shows three content blocks which i'm able to achieve styling with CSS.

However I want my homepage only to display these content blocks. This is obviously done in the Modify Sections page which I understand. However due to the styling of these content blocks these will appear on each of the other pages. Even those that i have only one content block specified in the sections page.

Code:
<div class="content">
        <?php page_content(1); ?>
    </div>
    <div class="bottomleft">
        <?php page_content(2); ?>
    </div>
    <div class="bottomright">
        <?php page_content(3); ?>
    </div>

The code snippet above is an example, I need some way of saying only show these DIV containers (bottomleft & bottomright) if these content blocks have any content.

If anyone is able to help me it would be greatly appreciated.




Logged
doc
Guest
« Reply #1 on: January 16, 2008, 10:20:30 AM »

Hello,

please have a look on this forum thread here.

Using the advanced forum help with the keywords: ob_start and block would provided some more information. If time allows, we put this information to the Help website.

Regards Christian
Logged
rdsaunders

Offline Offline

Posts: 3


« Reply #2 on: January 16, 2008, 10:37:49 AM »

Thank you for your quick response.

I shall attempt this today and feedback, thank you for the search criteria. I'm sure to have some reading to do.

I'm new at php i'm happy to sit with HTML/CSS but need to begin to understand PHP a little  huh



Logged
rdsaunders

Offline Offline

Posts: 3


« Reply #3 on: January 16, 2008, 12:18:59 PM »

Well its now working!

This is the code i utilised.

Code:
<!--  This routine checks for content in content area two before rendering the containers -->     
<?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
?>
   
<?php if ($content2<>"") { // Next test $content2 to see if there is something in it
    
echo "<div class=\"bottomleft\">\n";
    echo 
$content2;
    echo 
"\n</div><!-- close div#bottomleft-->\n";
}
?>


This needs to be in the template for each block you what to check and render on the page.

Ensure you change the variable name and change the page_content(2) number that relates to the block you are referring to.
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!