WebsiteBaker Support (2.8.x) > Templates, Menus & Design

Multiple Content Blocks

(1/1)

rdsaunders:
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>

--- End code ---

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.






[gelöscht durch Administrator]

doc:
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

rdsaunders:
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  :?



rdsaunders:
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";
}?>

--- End code ---

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.

Navigation

[0] Message Index

Go to full version