Getting content from a page or making global blocks 2...

chross

#15
I'm glad I found this solution here. Global content blocks is definitely something worth implementing for even better usability but not as high priority, of course.


Because my provider doesn't allow URL include, I am using the curl method as follows.

I added the following into the head section of my template:

<?php //--------PHP Blocks Script------------
function display_snippet($snippet){$ch = curl_init();$timeout = 5;curl_setopt ($ch, CURLOPT_URL, WB_URL.'/pages/snippet/'.$snippet.'.php');curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);$file_contents = curl_exec($ch);curl_close($ch);echo $file_contents;}
?>

In my pages I call the different blocks with load_snippet(testcontent);

Works perfectly fine for me.

Cheers

Gerard

Hi,

Thank you for your responses. I finally found the solution with the wrappermodule. The white border around the site was caused by the "blank" template wich can easily be modified by changing the backgroundcolor of the body. I don't know why I did not think about that earlier........

@Ruud
I'm not a programmer. Yet.....

@Erpe
Altough the problem is solved I'm still interested in that other solution so when you find it back I would appreciate it if you can post it here

Thank you all.  :-)

Regards,

Gerard

erpe0812

Hi Gerard,

this guestbook is made with a wrapper and a blank template, but I know, there was another solution that I tried before, posted in the forum, and it worked well too. It based on php-code in a code section, if I remember right. But don't know the thread  anymore.

So please try the search again, I hope you will be successfull.

rgds

erpe

Ruud

The guestbook module fetches the content using the current page_id and section_id. This way multiple guestbooks are possible  within one site.
When using the global block solution the page_id/section_id will be different. Therefore there is no content shown.

I think a wrapper solution will be your only option (unless you want to rewrite the guestbook module)

Ruud
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

Gerard

Hi Erpe,

Sure I did. Please don't think I do not do some digging before asking questions.. But did not found a suitable solution. I tried the wrappermodule wich should work using the blank template but it shows an ugly white border around the site. This was the best solution so far but I was'nt happy with it, neither will my customer do. Then I tried severall menublocks wich ended in messy menu's and strange behavior of them. They appear and disappear so I dislike to use more then one menublock. (In fact it should not any longer nessecary to use more menublocks since I use shwomenu2.) Then  I found a snippet to show the latest additions on a page. Very nice but I like to show all of them, not only the 10 latests. So finally I found the "global block" solution made by pcwacht wich is almost perfect for what I want to achieve and an very sophisticated one wich I like very much. But it  does not work for the guestbookmodul. I only wonder why. Maybe a small modification will do it all..

Regards,

Gerard

erpe0812

Hi,

please search the forum,

there is more than one solution for that.

rgds

erpe

Gerard

Great solution. It works fine for me. I used it for a multilingual site; a global block for a gallery of paintings (Just a normal wysiwygpage) and a list of exhibitions (type is the newsmodule)
I have one problem left: this trick seems not to work for the guestbookmodule. Has anyone an idea how to solve that?

Merry Christmas, everybody.

Regards,

Gerard

Ruud

Yes,

Doing this on a single page will actually load the module multiple times.
All the global block "tricks" will do that.

The only other solution is to use wrappers (iframes) and load different pages.
Using wrappers however will present other problems like reloading and scrolling within the iframe.

Ruud
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

mikejd

Hi Ruud,
Thanks for the suggestion. I have tried this and it works but still leaves me with the problem I am trying to overcome, namely using more than one instance of Bakery on one page results in error messages appearing on the page due to constants being defined more than once.

Also it will only link to sections from pages with public visibility not from hidden pages, and I was trying to keep my products pages hidden and just import the sections.

I think I am going to have to completely rethink the way I set up the shop page, probably using sub-pages with the various categories linked from the main page.

cheers,
Mike

Ruud

The problem is that the snippet uses variable names that are also used in the page. They are getting lost.

You could try to use this module: https://forum.websitebaker.org/index.php/topic,10674.0.html

It does the same as the script above, but you can add it as sections in your page.

Ruud
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

mikejd

I am trying this to see if it will resolve my problem with a listing of products in a small shop page. I have a number of categories of product and have created a separate,hidden, page for each using the Bakery module. I am then trying to call each section from the hidden pages into a main shop page.

I've followed the instructions above inserting the code suggested by John into a Code section. This does then display the section from the sub-page but it doesn't show anything from sections on the main page which follow it, ie a wysiwyg section below the code section.

Lotus

Worked for me aswell i think "global blocks" is a must have feature and you have done the neatest solution. Did a request for this feature.

https://forum.WebsiteBaker.org/index.php/topic,8731.0.html


knop3se


pcwacht

#1
Ok you know the deal...

You have a section wich you wanna show somewhere else?


Make a code section, paste:

// Change this to the section number you need!
$section_id = 65;

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

// Make sure there is one
if($query_sections->numRows() > 0) {
$section = $query_sections->fetchRow();
$section_id = $section['section_id'];
$module = $section['module'];
require(WB_PATH.'/modules/'.$module.'/view.php');
}



If you need this GLOBAL, then add following to your template:

<?php
// Change to the number you need!
$section_id 65;

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

// Make sure there is one
if($query_sections->numRows() > 0) {
$section $query_sections->fetchRow();
$section_id $section['section_id'];
$module $section['module'];
require(WB_PATH.'/modules/'.$module.'/view.php');

?>


How to get the section number:
Open admin, pages, choose the page with the section you need
Then choose manage section and click the section you want
you will see a link in the browsers address bar like :
http://localhost/wb260/admin/pages/modify.php?page_id=40#65
the last number is the section (65 in this case - 40 is the page_id)

Have fun!
John