Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 05:50:28 PM

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.
155545 Posts in 21714 Topics by 7736 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: 1 2 [3]   Go Down
Print
Author Topic: Global blocks - or how to get the same content on every page  (Read 21560 times)
mr-fan

Offline Offline

Posts: 1556


WWW
« Reply #50 on: May 31, 2010, 09:18:58 AM »

What else can i try?

Tnx, Housy

hi Housy,

try this one in code section or in your template... wink

Code:
<?php
// here your section 
$section_id 65;

// query for section call
$query_sections $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id' ");

// query to check if section exists and output with fitting mod view.php
if($query_sections->numRows() > 0) {
$section $query_sections->fetchRow();
$section_id $section['section_id'];
$module $section['module'];
require(WB_PATH.'/modules/'.$module.'/view.php');

?>

best regards
martin
Logged

 
Housy

Offline Offline

Posts: 39



« Reply #51 on: May 31, 2010, 03:46:35 PM »

What else can i try?

Tnx, Housy

hi Housy,

try this one in code section or in your template... wink

Code:
<?php
// here your section 
$section_id 65;

// query for section call
$query_sections $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id' ");

// query to check if section exists and output with fitting mod view.php
if($query_sections->numRows() > 0) {
$section $query_sections->fetchRow();
$section_id $section['section_id'];
$module $section['module'];
require(WB_PATH.'/modules/'.$module.'/view.php');

?>

best regards
martin

Martin I love you man grin

Thank you very much, finally working wink

Thank you both, Martin and Klaus.

Housy
Logged
mr-fan

Offline Offline

Posts: 1556


WWW
« Reply #52 on: May 31, 2010, 04:00:43 PM »

nice that it works for you!

best regards martin
Logged

 
lavric

Offline Offline

Posts: 10



« Reply #53 on: September 09, 2010, 12:49:32 PM »

Code:
               <!-- global block starts here -->
                <div id="topleft"> <!-- change to your favorite css #id -->
                <?php
                ob_start
();
                
page_content(2); //INFOBOX PAGE CONTENT 2 in my case
                
$topl=ob_get_contents();
                
ob_end_clean();
                if (
$topl=="") {
                
$section_id 65// ID from the section that stays always if pagecontent 2 has no content
                
$query_sec $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id' ");
                if(
$query_sec->numRows() > 0) {
                
$section $query_sec->fetchRow();
                
$section_id $section['section_id'];
                
$module $section['module'];
                require(
WB_PATH.'/modules/'.$module.'/view.php');
                }
                } else {
                echo 
'<div align="center">';
                echo 
$topl;
                echo 
'</div>';
                }
                
?>

                </div>
                <!-- end of the global block -->


Hi guys,

i use this piece of code for global blocks!

I've got it from vyni!

The Trick is that you can have default view for a global block (with the section_id you choose) and if you want another content on one or more sites only set up a section and set it up to the content of the global block - and on this page the content is like you want it!

regards martin


This is WOW USEFUL!!! THANKS MAN!!!
Logged

I thought it wasn't too much trouble, but it was too much to ask...
tkche

Offline Offline

Posts: 12


« Reply #54 on: October 30, 2010, 11:49:42 AM »

Hi,
I am trying to make a global block for a contact-form on my template.
the above code works great and gets the job done, but for some reason it includes the CSS style into the page's code.
any ideas?
Logged
edwardca

Offline Offline

Posts: 5


« Reply #55 on: November 02, 2010, 03:50:50 PM »

Hi!

If your server does not allow the include-command in your template's index.php
<?php include (WB_URL."/pages/blocks/block1.php"); ?>
due to security-settings, try this instead:

<?php
$handle = fopen (WB_URL."/pages/blocks/block1.php", "r");
while (!feof($handle))
   {
    $buffer = fgets($handle, 4096);
    print_r ($buffer);
   }
 ?>

Works well smiley

greets masju

Yes!  Solved my problem - you rock dude!!
Logged
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2297



WWW
« Reply #56 on: March 07, 2012, 10:16:42 PM »

The solution. The globalBlock snippet.

http://www.websitebaker2.org/forum/index.php/topic,23587.msg159797.html#msg159797
Logged

Professional WebsiteBaker Solutions
Pages: 1 2 [3]   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!