WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: pcwacht on January 08, 2006, 03:55:48 PM

Title: Global blocks - or how to get the same content on every page
Post by: pcwacht on January 08, 2006, 03:55:48 PM
What you need to do to make the 'globalblocks' work:

1 - the 'blank' template wich come with wb26x, it has only <?php page_content(); ?> in it's index.php, nothing more, this will be the template for the globalblocks
2 - make a menuitem 'blocks' and set it hidden (this will be the place to store the blocks)
3 - make a new page, 'block1', choose the 'blank' template for it, choose the 'blocks' page as parent and give it the content you want
4 - same as 3 for the second 'globalblock' and call this 'block2'
5 - change your current template's index.php by adding the two pages you just made

<?php include (WB_URL."/pages/blocks/block1.php"); ?> and
<?php include (WB_URL."/pages/blocks/block2.php"); ?>
 at the position you want it.

What it does:
You made 2 pages, block1 and block2 and you choose the minimalistic template for it, so when you call those pages in your browser (http://yourdomain/pages/blocks/block1.php (or block2.php) you only will see what you entered, nothing more!

By including those two blocks in your template, the output will be placed in your normal pages at the place you have put the include-code.

That's basicly it.
Nothing fancy, nothing tricky, just using the system.

Benefits are:
one block for all pages
one time edit to change a block
much easier to admin
and it will show up in the search page (allso in the news-comments pages)

Title: Re: Global blocks - or how to get the same content on every page
Post by: rabsaul on February 27, 2006, 11:03:27 AM
One thing you don't mention here is how to edit these blocks. Are they visible and editable from the Pages section of the Admin, or do they need to be edited manually?

Thanks!
Title: Re: Global blocks - or how to get the same content on every page
Post by: wwwMARKLEYcouk on February 27, 2006, 11:10:45 AM
One thing you don't mention here is how to edit these blocks. Are they visible and editable from the Pages section of the Admin, or do they need to be edited manually?

Thanks!
they will show up in the pages section as number 3 states:

Quote from: pcwacht
3 - make a new page
Title: Re: Global blocks - or how to get the same content on every page
Post by: rabsaul on February 28, 2006, 09:14:42 AM
They work great! Excellent! :)
Title: Re: Global blocks - or how to get the same content on every page
Post by: kibmcz on March 05, 2006, 12:13:36 PM
when i put <?php include (WB_URL."/pages/blocks/block1.php"); ?> in my template i am locked out of executing php in the current path (eg. http://www.yourdomain.com/)  for a random times. Yet my blog at /blog still worked ?
Title: Re: Global blocks - or how to get the same content on every page
Post by: pcwacht on March 05, 2006, 01:22:18 PM
might be due to the code in your block1 page

try only an echo 'Hello world'; to test this.

John
Title: Re: Global blocks - or how to get the same content on every page
Post by: kibmcz on March 05, 2006, 01:45:38 PM
might be due to the code in your block1 page

try only an echo 'Hello world'; to test this.

John

Thanks that helped... it was the WYSIWYG module. it dosn't work in the global block. Not a prob as long as form module works (and it does).
Title: Re: Global blocks - or how to get the same content on every page
Post by: kickarse on April 18, 2006, 04:44:16 PM
Good idea! I think I'm going to use this on a site I'm developing now.
Title: Re: Global blocks - or how to get the same content on every page
Post by: Wirus on May 09, 2006, 12:47:51 PM
Is possible make second block without absolute path ?

Defined NOT as:
<?php include (WB_URL."/pages/blocks/block2.php"); ?>

but something like this:
<?php include ("../pages/blocks/block2.php"); ?>

Absolute url fopen is often forbiden by server...

Thanks
Title: Re: Global blocks - or how to get the same content on every page
Post by: pcwacht on May 09, 2006, 01:02:38 PM
Don't think it can be done

I tried to but got warnings about missing config(.)php in the called file


But why do you need it?

John
Title: Re: Global blocks - or how to get the same content on every page
Post by: Wirus on May 10, 2006, 08:44:13 AM
Including complete URL is forbiden on my server. (security hole) I can include only local path. This is possible but system dont change template of included page (is set to blank) and include it with template of actual page (round).
Title: Re: Global blocks - or how to get the same content on every page
Post by: pcwacht on May 10, 2006, 10:59:49 AM
Have you seen my other solution?
This don't need path's etc...

http://forum.WebsiteBaker.org/index.php/topic,3217.0.html

Another option would be to abslote the link, something like /home/somepath/http/pages/page12.php


John
Title: Re: Global blocks - or how to get the same content on every page
Post by: rabsaul on May 11, 2006, 11:09:56 PM
Is possible make second block without absolute path ?

Defined NOT as:
<?php include (WB_URL."/pages/blocks/block2.php"); ?>

but something like this:
<?php include ("../pages/blocks/block2.php"); ?>

Absolute url fopen is often forbiden by server...

Thanks
That's not an absolute path. An absolute path would be http://www.etcetc.
Title: Re: Global blocks - or how to get the same content on every page
Post by: pcwacht on May 12, 2006, 12:16:27 PM
Quote
That's not an absolute path. An absolute path would be http://www.etcetc.

Path = filebased
URL is webserver based

http://www.somedomain.com/somepath/somefile.php = absolute url
/home/sites/site300/web/somepath/somefile.php = absolute path (on linux)
../somepath/somefile.php = relative (path or url)


John
Title: Re: Global blocks - or how to get the same content on every page
Post by: DGEC on June 21, 2006, 10:48:00 PM

                    ....
5 - change your current template's index.php by adding the two pages you just made

<?php include (WB_URL."/pages/blocks/block1.php"); ?> and
<?php include (WB_URL."/pages/blocks/block2.php"); ?>
 at the position you want it.


One suggestion about this code: rather than using the literal  /pages/, everyone should probably get in the habit of using the WB_PATH variable, especially for templates, snippets, modules, etc. That way if someone has a different path or no path, your brilliant code will still work  :-D

So instead of:

     
Code: [Select]
<?php include (WB_URL."/pages/blocks/block1.php"); ?>
you would instead code  (I think - this isn't tested yet)

     
Code: [Select]
<?php include (WB_URL WB_PATH "/blocks/block1.php"); ?>
Title: Re: Global blocks - or how to get the same content on every page
Post by: eddyfever on February 21, 2007, 06:51:16 PM
So strange this never with me, it looks like it is not alloud to insert a .php or something.
does anybody know what it can be.

preview: under title (poll)
http://www.rawrock.nl/site (http://www.rawrock.nl/site)
Title: Re: Global blocks - or how to get the same content on every page
Post by: kweitzel on February 21, 2007, 06:56:46 PM
if it does not work, try curl instead:

Code: [Select]
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, WB_URL.'/pages/pagename.php');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
// display file
echo $file_contents;

cheers

Klaus
Title: Re: Global blocks - or how to get the same content on every page
Post by: eddyfever on February 21, 2007, 07:03:58 PM
can you maybe explain how i can use this?

Nevermind: it works with your solution!!!!

Vielen herzlichen Dank. Abende lang hab ich gesucht und endlich hat es geklappt!!!!!!!
Title: Re: Global blocks - or how to get the same content on every page
Post by: eddyfever on February 21, 2007, 07:27:43 PM
And when i use more blocks in my template do i have to change then something in the script?
this because now it doesnt load theright site of my template when i use it more times in my template.
Title: Re: Global blocks - or how to get the same content on every page
Post by: kweitzel on February 22, 2007, 07:30:42 AM
Hmm... haven't tried it yet multiple times (no need to). For which types of info do you still need it?

cheers

Klaus
Title: Re: Global blocks - or how to get the same content on every page
Post by: aggiedad on June 07, 2007, 05:24:08 AM
Can this be used with more than two blocks?

I was trying this technique with more than two blocks and it caused my site to hang-up. First I tried it by just adding an additional block. Then when that didn't work, tried a second hidden page -- things still didn't work.

Any thoughts?

Thanks!

Don Simmons
Texas
Title: Re: Global blocks - or how to get the same content on every page
Post by: weiry on January 06, 2009, 07:23:46 AM
if it does not work, try curl instead:

Code: [Select]
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, WB_URL.'/pages/pagename.php');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
// display file
echo $file_contents;

cheers

Klaus
Thank you for this option Klaus. No matter what I did, I couldn't get it to work with the other options, even after reading numerous related threads. But this curl worked straight away.

Cheers.
Title: Re: Global blocks - or how to get the same content on every page
Post by: sare on January 30, 2009, 10:44:51 AM
Same here.

Nothing worked with the normal include, at best it showed the wrong template with the include and broke all page_content-functions that were after that in the template code.

This cURL code worked like magic after finding the right URL for it to use.

If you can't get the cURL code to work, try with and without the www-part in the WB_URL. I didn't use it at first, and got 404's (not found).

Hope this saves somebody else the 3 hours I spent scrathing my head...
Title: Re: Global blocks - or how to get the same content on every page
Post by: kweitzel on January 30, 2009, 11:15:03 AM
Since cURL is actually an Wrapper for URLs you obviously will need to feed it with an URL and not a path. It will also only work, if it is activated on the Server.

cheers

Klaus
Title: Re: Global blocks - or how to get the same content on every page - Easy solution
Post by: masju on January 31, 2009, 04:58:16 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 :-)

greets masju
Title: Re: Global blocks - or how to get the same content on every page
Post by: kweitzel on January 31, 2009, 09:06:28 PM
That works as well if fopen is allowed on the host. Sometimes you find this one to be disabled as well.

Info: http://phpsec.org/projects/phpsecinfo/tests/allow_url_fopen.html

cheers

Klaus
Title: Re: Global blocks - or how to get the same content on every page
Post by: lousou76 on March 04, 2009, 11:33:07 PM
Excellent work Klaus!

It's a nice way of using global block sections that could be edited once instead of copying content form one page to another.

I guess the best way to do this would be a new nice page_content() function that could take 2 arguments instead of one. The page_id and the section_id.

That way you could just use for example <? page_content(1,3);  ?> to display content from another page on your site. You could also add this code on a Code section anywhere on your current page and show the same content with some other page.

I would advise against using curl to do this. If it hangs or it delays the page never loads or loads empty.

So lets see how to slightly change the page_content function, or add a new one that does what we want so we can have global blocks anywhere.

I ll have more on that later..

Regards,
LS
 
Title: Re: Global blocks - or how to get the same content on every page
Post by: lousou76 on March 05, 2009, 12:05:59 AM
Well it's really very simple.

If you want to display content from another page (regardless of what type of module it is) you only need to know the page_id ans the section_id of the content you need to show.

Lets say you are on /admin/pages/modify.php?page_id=16

and you want to show content from page_id=14 section_id=2.

You just add a code section on the current page and put the code
Code: [Select]
global $wb;
$wb->page_id = 14;
page_content(2);
$wb->page_id = 16;  //I am not sure this is really necessary but just in case.

This will display the exact type of module and content on the current section with page_id=14 and section_id=2.

Regards,
LS
Title: Re: Global blocks - or how to get the same content on every page
Post by: mr-fan on March 05, 2009, 09:23:48 AM
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
Title: Re: Global blocks - or how to get the same content on every page
Post by: weiry on May 13, 2009, 08:11:38 AM
I have found that this code works fine for calling in a block on every page that I have created on a hidden page.

However, if I have content already on another the page in that div area i.e. on the Contact Us page, the block I want on every page disappears and the text on the Contact Us page is there okay in that div area.

I am sure that it is a quick php thing, but can't see how to fix.

Any thoughts?
Title: Re: Global blocks - or how to get the same content on every page
Post by: mr-fan on May 13, 2009, 12:16:20 PM
link? more details? code?.......my telephaty-power is burst up.... :-D
Title: Re: Global blocks - or how to get the same content on every page
Post by: kweitzel on May 13, 2009, 09:33:38 PM
@weiry: above code is working as designed, it is meant to do this! If no content assigned to this div call the hidden div.

You can just try to hard-code an include if you don't want this feature ... set the "hidden" page to template blank and then:
Code: [Select]
<?php include WB_URL.&#39;/pages/name_of_hidden_page.php&#39;; ?>
If include does not work (disabled), use the cURL (if installed on server) like described further above instead.

cheers

Klaus
Title: Re: Global blocks - or how to get the same content on every page
Post by: weiry on May 14, 2009, 02:42:09 AM
@mrfan and @klaus
Sorry, was trying to make things a little too cute and should have used the curl instead.

What I wanted, was one hidden page that may contain many hidden sections on it for a variety of different divs across many pages. I wanted to call in specific sections for certain pages determined by the template being used. i.e. 3 pages will reference one section for 1 div area (right-hand column) and 4 pages will reference another section for 1 div area (main content). That way the client changes it once on one hidden page and it is picked up across the different pages.

P.S. Just a note, I remembered there was a Droplets module ShowSection, so I was able to call in the specific section and then call in the remainder of the text on the page in that div if it had any. You could either put this Droplet as a Code section on the particular pages, or call it in through the index.php file. So a couple of solutions to my problem.

Hope that helps someone else.

Cheers.
Title: Re: Global blocks - or how to get the same content on every page
Post by: lousou76 on May 15, 2009, 01:27:08 PM
I use the below code all the time and it works great.
You can have the source page hidden or not.
All you have to do is put a code section instead of a block
and know the page_id and the section number you wish to display.

in the below example I display section 2 of page 14 on current section of page 16
You can display more than one on the same page and copy entire pages this way keeping the same template.
libcurl is buggy and will show empty block or timeout if something is wrong.
The below way replicates directly trhough the db using wb own methods.

Regards,
LS

Code: [Select]
global $wb;
$wb->page_id = 14;
page_content(2);
$wb->page_id = 16;  //I am not sure this is really necessary but just in case.

Title: Re: Global blocks - or how to get the same content on every page
Post by: Hans on May 16, 2009, 02:43:46 PM
Hi lousou76
I tried your code and it works great but not with an image gallery. Is there a way to make that work too?
Thanks
Hans
Title: Re: Global blocks - or how to get the same content on every page
Post by: lousou76 on May 18, 2009, 02:18:31 PM
Hi Hans,
I don'nt think that is code related.

What the code below does is it changes the current page_id to the page that has the section you wish to display and then it prints the section number you want.

If the gallery works on the original page it should work on the other page as well.
At least it works on my tests.
I don;t know what else could be wrong.
I 've tested it with my gallery, a form etc and I had no error.

Regards,
LS


Hi lousou76
I tried your code and it works great but not with an image gallery. Is there a way to make that work too?
Thanks
Hans
Title: Re: Global blocks - or how to get the same content on every page
Post by: Hans on May 18, 2009, 07:15:39 PM
Hi lousou76
Thanks for your answer. Tried it again on an other install and it worked fine. Don't know why it failed the first time, I will try again and post if necessary.
Thanks again
Hans
Title: Re: Global blocks - or how to get the same content on every page
Post by: crnogorac081 on August 18, 2009, 11:21:50 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 Martin,

Could you explain me pls what is the point of this code ?

 page_content(2); //INFOBOX PAGE CONTENT 2 in my case

As if you have for example left content box (1) and right sidebar (2) , If you want your block on right side, you will put this piece of code right before <?php  page_content(2); ?> , right ??

So I dont understand the point, or I am missing something... ??

cheers
Title: Re: Global blocks - or how to get the same content on every page
Post by: mr-fan on August 19, 2009, 07:54:38 PM
hi ivan,

it it very simpel to explain!

if you have for eg. page_content(2); in your template for the second block!

replace it with this code and change the section ID to your needs!

so you've get a standart section that is shown in the second block (the section you set up)

BUT if you setup on one of your pages a different page_content(2); (manage sections) the default view (section) change ONLY on this site to the block 2 content you like!

example page from me: (only german - not valide - not my best one... :wink:)

http://www.mr-vilsbiburg.de/pages/maschinenring--e.v.-/vorstand.php (http://www.mr-vilsbiburg.de/pages/maschinenring--e.v.-/vorstand.php)

under "INFOBOX" the standardsection is a codesection with the "oneliner" droplet

like on this site, too:

http://www.mr-vilsbiburg.de/pages/dienstleistungen-gmbh/winterdienst.php (http://www.mr-vilsbiburg.de/pages/dienstleistungen-gmbh/winterdienst.php)

but on many many other sites there is a block 2 setup in the page settings itself and then the viewport is on the specialcontent for this page!

Code: [Select]
<?php //pseudocode
if block 2 has content - echo block 2 ....else echo section that is set in the codesnippet...

i hope its clear now - english is not my language - like you, too  :-D

regards martin

Title: Re: Global blocks - or how to get the same content on every page
Post by: crnogorac081 on August 19, 2009, 08:25:04 PM
Aldo I didnt understood this part,
Quote
BUT if you setup on one of your pages a different page_content(2); (manage sections) the default view (section) change ONLY on this site to the block 2 content you like!

I now understand that this, your code, contains both <?php  page_content(2); ?> line,  and the coded from first post :))

So basicly you can choose to put your code or these 2 pieces of php :)

cheers

Title: Re: Global blocks - or how to get the same content on every page
Post by: mr-fan on October 04, 2009, 08:42:43 PM
hi,

i'am writing a tutorial for "global blocks" and with this work i worked a lot with all the mentioned options and possibilitys....

i've just combined my version (vyni's) and louSou's version to this one - it seems to work realy good!

But i've asking for some people who test this a little bit more!!

Code: [Select]
               <!-- global block starts here -->
                <div id="topleft"> <!-- change to your favorite css #id -->
                <?php
                ob_start
();
                
page_content(2); //PAGE CONTENT who should be replaced with global block
                
$topl=ob_get_contents();
                
ob_end_clean();
                if (
$topl=="") {
                                 global 
$wb;
                                 
$wb->page_id 14;  // page_id of the global block
                                 
page_content(1);    // set up the block to show
                                
} else {
                echo 
$topl;
                }
                
?>

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

it seems that this will we the most flexible way to setup a global block in a template! and you can choose to get different content on some pages, too!

have fun!

martin
Title: Re: Global blocks - or how to get the same content on every page
Post by: kweitzel on October 04, 2009, 10:39:36 PM
Hmm ... I personally would wrap the DIV in the output as well since it then hides headers if they are ot needed. A bit like this:

Code: [Select]

                <!-- global block starts here -->
                <?php
                ob_start
();
                
page_content(2); //PAGE CONTENT who should be replaced with global block
                
$topl=ob_get_contents();
                
ob_end_clean();
                if (
$topl=="") {
                    global 
$wb;
                    
$wb->page_id 14;  // page_id of the global block ?>

                    <div id="topleft"> <!-- change to your favorite css #id -->
                    <?php page_content(1);    // set up the block to show ?>
                    </div>
                    <?php
                
} else {
                    echo 
$topl;
                }
                
?>

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


cheers

Klaus
Title: Re: Global blocks - or how to get the same content on every page
Post by: mr-fan on October 04, 2009, 11:09:22 PM
dear klaus,

yes you are right - but have you tested it?

i only want that this code work on other testenvironments, too....

this would be my final example for the tuttorial..... :wink:

tutorial would be about include, cURL, get by section, get by page_content (like the mentioned code) and put this together with the ouput buffer....to get it dynamically with a second/third block in the template....

regards martin
Title: Re: Global blocks - or how to get the same content on every page
Post by: kweitzel on October 05, 2009, 12:09:15 AM
This is how I usually do my includes, since I don't like having the empty DIV within the template, maybe even styled and then no content in it.

But then again, I use them global blocks a bit differently, since they can also contain nothing!

Basically: If local block is empty try global block, if that one is empty show nothing" ...

cheers

Klaus
Title: Re: Global blocks - or how to get the same content on every page
Post by: Housy on May 29, 2010, 08:40:50 PM
if it does not work, try curl instead:

Code: [Select]
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, WB_URL.'/pages/pagename.php');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
// display file
echo $file_contents;

Thank you Klaus, that works, if i use WYSIWIG editor but if i want to create a form within admin area (if i use the built-in form module) then it doesn't work and i don't know where is the problem. For example if i create a name and e-mail field and i include that page within my template file, then it's printed out, it means that i see the form on my website but when i press the send/submit button, i'm redirected to a blank page, nothing happens actually and the link looks like this --> http://localhost/wb/pages/blocks/form.php#wb_33

If i access the link directly, like this --> http://localhost/wb/pages/blocks/form.php, then everything works fine, so the problem must be somewhere else, maybe i should set some setting or what, if you could help me please, cause i would really like to have a form on every single page but unfortunately that doesn't work as it should or maybe i'm stupid heh =D

Thank you, Housy
Title: Re: Global blocks - or how to get the same content on every page
Post by: kweitzel on May 29, 2010, 09:25:26 PM
Have you tried the droplet sectionpicker instead?

cheers

Klaus
Title: Re: Global blocks - or how to get the same content on every page
Post by: Housy on May 30, 2010, 01:00:32 PM
Have you tried the droplet sectionpicker instead?

I have found something, but i'm not quite sure if that is what you had in mind --> CLICK (http://www.websitebakers.com/pages/droplets/official-library/content/showsection.php)
I don't understand actually, how that works to be honest :? What should i download, the droplet module and then what? :|

Could you please explain this more easily Klaus?

Thank you, Housy
Title: Re: Global blocks - or how to get the same content on every page
Post by: kweitzel on May 30, 2010, 02:09:03 PM
Depending on the installed WB Version the Module is already included, have a look at the admin tools. A bit more info can be found here: http://www.websitebakers.com/pages/droplets/about-droplets.php

You copy the droplet code and past it into a "new" droplet which you can create in the admin of your WebsiteBaker installation. Name the droplet exactly like found on the site "ShowSection" and call it with [[showsection?section=xx]] (replace xx with the ID of your Section).

The Call can be placed in your template or in a section.

cheers

Klaus
Title: Re: Global blocks - or how to get the same content on every page
Post by: Housy on May 31, 2010, 01:03:49 AM
Depending on the installed WB Version the Module is already included, have a look at the admin tools. A bit more info can be found here: http://www.websitebakers.com/pages/droplets/about-droplets.php

You copy the droplet code and past it into a "new" droplet which you can create in the admin of your WebsiteBaker installation. Name the droplet exactly like found on the site "ShowSection" and call it with [[showsection?section=xx]] (replace xx with the ID of your Section).

The Call can be placed in your template or in a section.

cheers

Klaus

Tnx Klaus but unfortunately that works only for the WYSIWIG editor and not for the built-in form module :|, cause i read that here in this theme --> CLICK (https://forum.WebsiteBaker.org/index.php/topic,12279.msg110452.html#msg110452) and i also tryed to include form section but i get the error --> "Error in: showsection?section=33, no correct returnvalue.".

I just want to have a form on every single page, is that really so hard to do? This problem is killing me, i tryed everything but no result, nothing works as it should :-(

What else can i try?

Tnx, Housy
Title: Re: Global blocks - or how to get the same content on every page
Post by: kweitzel on May 31, 2010, 08:16:38 AM
Things you can still do: Create a formpage for the submission action (make it hidden or something) and then:

1) Hardcode it into your template, like with the searchbox or the loginbox
2) Create a droplet (there are searchbox and loginbox available as sample)

but as action you take the submission of the formpage

cheers

Klaus
Title: Re: Global blocks - or how to get the same content on every page
Post by: mr-fan 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
Title: Re: Global blocks - or how to get the same content on every page
Post by: Housy 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
Title: Re: Global blocks - or how to get the same content on every page
Post by: mr-fan on May 31, 2010, 05:00:43 PM
nice that it works for you!

best regards martin
Title: Re: Global blocks - or how to get the same content on every page
Post by: lavric 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!!!
Title: Re: Global blocks - or how to get the same content on every page
Post by: tkche 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?
Title: Re: Global blocks - or how to get the same content on every page - Easy solution
Post by: edwardca 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 :-)

greets masju

Yes!  Solved my problem - you rock dude!!
Title: Re: Global blocks - or how to get the same content on every page
Post by: Ruud on March 07, 2012, 10:16:42 PM
The solution. The globalBlock snippet.

https://forum.WebsiteBaker.org/index.php/topic,23587.msg159797.html#msg159797