Author Topic: Global blocks - or how to get the same content on every page  (Read 55634 times)

mr-fan

  • Guest
Re: Global blocks - or how to get the same content on every page
« Reply #50 on: May 31, 2010, 10:18:58 AM »
What else can i try?

Tnx, Housy

hi Housy,

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

Code: [Select]
<?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 = &#39;$section_id&#39; ");

// 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[&#39;section_id&#39;];
$module $section[&#39;module&#39;];
require(WB_PATH.&#39;/modules/&#39;.$module.&#39;/view.php&#39;);

?>

best regards
martin

Offline Housy

  • Posts: 39
  • Gender: Male
Re: Global blocks - or how to get the same content on every page
« Reply #51 on: May 31, 2010, 04:46:35 PM »
What else can i try?

Tnx, Housy

hi Housy,

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

Code: [Select]
<?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 = &#39;$section_id&#39; ");

// 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[&#39;section_id&#39;];
$module $section[&#39;module&#39;];
require(WB_PATH.&#39;/modules/&#39;.$module.&#39;/view.php&#39;);

?>

best regards
martin

Martin I love you man :-D

Thank you very much, finally working :wink:

Thank you both, Martin and Klaus.

Housy

mr-fan

  • Guest
Re: Global blocks - or how to get the same content on every page
« Reply #52 on: May 31, 2010, 05:00:43 PM »
nice that it works for you!

best regards martin

Offline lavric

  • Posts: 10
  • Gender: Male
  • blond...
Re: Global blocks - or how to get the same content on every page
« Reply #53 on: September 09, 2010, 01:49:32 PM »
Code: [Select]
               <!-- 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 = &#39;$section_id&#39; ");
                if(
$query_sec->numRows() > 0) {
                
$section $query_sec->fetchRow();
                
$section_id $section[&#39;section_id&#39;];
                
$module $section[&#39;module&#39;];
                
require(WB_PATH.&#39;/modules/&#39;.$module.&#39;/view.php&#39;);
                
}
                } else {
                echo &
#39;<div align="center">&#39;;
                
echo $topl;
                echo &
#39;</div>&#39;;
                
}
                
?>

                </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!!!
I thought it wasn't too much trouble, but it was too much to ask...

Offline tkche

  • Posts: 12
Re: Global blocks - or how to get the same content on every page
« Reply #54 on: October 30, 2010, 12:49:42 PM »
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?

Offline edwardca

  • Posts: 5
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 :-)

greets masju

Yes!  Solved my problem - you rock dude!!

Offline Ruud

  • Posts: 3660
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development

 

postern-length