Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 27, 2012, 03:10:55 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter
hier
und auf unserer
neuen Webseite
.
155555
Posts in
21715
Topics by
7737
Members
Latest Member:
gx-world
WebsiteBaker Community Forum
English
Help & Support
(Moderators:
Argos
,
badknight
)
How can I call the content of a page into a fixed content block?
Pages: [
1
]
Go Down
Author
Topic: How can I call the content of a page into a fixed content block? (Read 2830 times)
sgharris
Offline
Posts: 18
How can I call the content of a page into a fixed content block?
«
on:
May 02, 2008, 03:24:34 PM »
Right now, I'm calling a text file using the following code:
<?php include(WB_PATH.'/media/upcoming.txt');?>
But that text file is, essentially, the same as another existing page (Upcoming Events). It would be nice to only have to update it once.
I've tried a few things, but just don't seem to have the php knowledge to do this.
Any help would be appreciated.
Steve
www.blyc.bio-geek.com
Logged
Ruud
WebsiteBaker Org e.V.
Offline
Posts: 2298
Re: How can I call the content of a page into a fixed content block?
«
Reply #1 on:
May 02, 2008, 10:37:20 PM »
Quote from: sgharris on May 02, 2008, 03:24:34 PM
Right now, I'm calling a text file using the following code:
<?php include(WB_PATH.'/media/upcoming.txt');?>
But that text file is, essentially, the same as another existing page (Upcoming Events). It would be nice to only have to update it once.
I've tried a few things, but just don't seem to have the php knowledge to do this.
Any help would be appreciated.
Steve
www.blyc.bio-geek.com
Try this snippet:
Code:
<?php
$sid
=
53
;
$gc
=
$database
->
query
(
"SELECT content FROM "
.
TABLE_PREFIX
.
"mod_wysiwyg WHERE section_id = '"
.
$sid
.
"'"
);
$rc
=
$gc
->
fetchRow
();
echo
$rc
[
'content'
];
?>
Set $sid to the section you like to use (must be a mod_wysiwyg section)
You can find the section ID when hovering your mouse over the section in the "admin->pages->manage sections" page and read the url in the statusbar of your browser.
The section is the last part of the url (
http://yourserver/admin/pages/modify.php?page_id=10#
53
)
Good luck
Ruud
Logged
Professional WebsiteBaker Solutions
sgharris
Offline
Posts: 18
Re: How can I call the content of a page into a fixed content block?
«
Reply #2 on:
May 13, 2008, 02:59:03 PM »
Thanks a bunch! It works great!
(well, once I remembered to changed the $sid= to the correct page number, that is)
Logged
thefly
Offline
Posts: 21
Re: How can I call the content of a page into a fixed content block?
«
Reply #3 on:
May 16, 2008, 03:46:13 PM »
Thanks, Ruud, too!
But I've noticed that hovering mouse on the page shows not section, but page ID, so this code work:
Code:
$pid = 52;
$gc = $database->query("SELECT content FROM ".TABLE_PREFIX."mod_wysiwyg WHERE page_id = '".$pid."'");
$rc = $gc->fetchRow();
echo $rc['content'];
Thanks again!
Asen :)
Logged
smile!
spida
Offline
Posts: 203
Re: How can I call the content of a page into a fixed content block?
«
Reply #4 on:
July 10, 2008, 04:04:03 PM »
Hi,
I am also playing around with the script. Since I want to include news, I changed it a bit to
Code:
$pid = 2;
$gc = $database->query("SELECT content FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = ' ".$pid." ' ");
$rc = $gc->fetchRow();
echo $rc['content'];
But I am getting an error message as the result:
Quote
Fatal error: Call to a member function fetchRow() on a non-object in C:\xampplite\htdocs\site\modules\code\view.php(30) : eval()'d code on line 3
Has someone an idea what I have to use instead of or additional with fetchRow?
Best regards,
spida
Logged
Ruud
WebsiteBaker Org e.V.
Offline
Posts: 2298
Re: How can I call the content of a page into a fixed content block?
«
Reply #5 on:
July 10, 2008, 08:43:21 PM »
Quote from: spida on July 10, 2008, 04:04:03 PM
Code:
$gc = $database->query("SELECT content FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = ' ".$pid." ' ");
"content" is not a field in the mod_news_posts table.
use
content_short
or
content_long
instead of
content
.
Cheers,
Ruud
Logged
Professional WebsiteBaker Solutions
spida
Offline
Posts: 203
Re: How can I call the content of a page into a fixed content block?
«
Reply #6 on:
July 11, 2008, 10:04:34 AM »
Hi Ruud,
thank you very much for your hint. That was the cause of course!
Regards,
spida
«
Last Edit: July 11, 2008, 03:51:49 PM by spida
»
Logged
Argos
Moderator
Offline
Posts: 2161
Re: How can I call the content of a page into a fixed content block?
«
Reply #7 on:
July 11, 2008, 03:48:55 PM »
An alternative:
Code:
<?php
$section_id
=
XX
;
$query_sections
=
$database
->
query
(
"SELECT section_id,module FROM "
.
TABLE_PREFIX
.
"sections WHERE section_id = '
$section_id
' "
);
if(
$query_sections
->
numRows
() >
0
) {
$section
=
$query_sections
->
fetchRow
();
$section_id
=
$section
[
'section_id'
];
$module
=
$section
[
'module'
];
require(
WB_PATH
.
'/modules/'
.
$module
.
'/view.php'
);
}
?>
Logged
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase:
http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
spida
Offline
Posts: 203
Re: How can I call the content of a page into a fixed content block?
«
Reply #8 on:
July 11, 2008, 03:53:20 PM »
Hi Argos,
what's the benefit of your script? Could you please explain to these PHP idiots like me
Kind regards,
spida
Logged
Argos
Moderator
Offline
Posts: 2161
Re: How can I call the content of a page into a fixed content block?
«
Reply #9 on:
July 11, 2008, 03:59:19 PM »
I don't know, I'm an idiot with php as well
I just happened to be doing the same as you, and the code I gave was the one I found after searching the forums. I works fine, and can be used for not only WYSIWYG I think. So if you have problems with the first code, try this one.
Logged
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase:
http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
pcwacht
AddOn Development
Offline
Posts: 2859
Re: How can I call the content of a page into a fixed content block?
«
Reply #10 on:
July 11, 2008, 08:48:50 PM »
Spida's code fetches only a field from the database, in his case the content_short field from the news table
Argos's code uses WB build in routines to show a whole section, section can be anything.
Argos's code is allso used for global blocks
Have fun,
John
Logged
http://www.ictwacht.nl
= Dutch ICT info
http://www.pcwacht.nl
= My first
both still work in progress, since years.....
Ruud
WebsiteBaker Org e.V.
Offline
Posts: 2298
Re: How can I call the content of a page into a fixed content block?
«
Reply #11 on:
July 16, 2008, 01:22:35 PM »
One little problem with Argos' code.
When you use this in a code section the folloing sections are not handled anymore.
By using the variable '$query_sections' as the query result, it destroys the original $query_sections from the framework.functions
.php.
Any other sections behind a codeblock with this snippet will not be shown anymore.
This code is modified so any following sections will still work.
Code:
$section_id = xx;
$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');
}
Ruud
Logged
Professional WebsiteBaker Solutions
Argos
Moderator
Offline
Posts: 2161
Re: How can I call the content of a page into a fixed content block?
«
Reply #12 on:
July 16, 2008, 02:40:33 PM »
Thanks for the update Ruud!
Logged
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase:
http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
spida
Offline
Posts: 203
Re: How can I call the content of a page into a fixed content block?
«
Reply #13 on:
July 18, 2008, 08:52:58 PM »
Thanks to all you guys for explanations, and for the update code too.
keep on going, websitebaker!
Logged
Pages: [
1
]
Go Up
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
=> Security Announcements
=> Documentation
=> WebsiteBaker Website Showcase
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
=====> Modules / Extensions
===> Suggestions
===> Software bugs
=> Help & Support
=> Modules
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
=> jQuery
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
=> Archive (posts up to 2007)
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
=====> Module / Extensions
===> Vorschläge
===> Softwarefehler
===> Erfahrungs und Testberichte
=> Hilfe/Support
=> Module & Snippets
=> Templates & Design
=> Tutorials
=> jQuery
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...