Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 26, 2012, 05:01:11 PM
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
.
155544
Posts in
21714
Topics by
7736
Members
Latest Member:
chris85
WebsiteBaker Community Forum
English
Help & Support
(Moderators:
Argos
,
badknight
)
Accessing SQL from iframe on code page
Pages: [
1
]
Go Down
Author
Topic: Accessing SQL from iframe on code page (Read 871 times)
richwingerter
Offline
Posts: 4
Accessing SQL from iframe on code page
«
on:
January 28, 2011, 01:48:51 AM »
I have a copy of Website Baker 2.6.7 that I've been working with for some time and I'd like to put up a page where I show information from the MySQL database within an iframe. However, if I try to put any PHP code in the iframe, it displays part of the code, not the results of running the code.
I've tried various combinations of ways, including creating a code page in the administrator and loading that code page into the iframe. That's loads and runs, but it shows the headers, footers and other columns of the site, not just the content for the page. If I write a static HTML page, it loads okay, but that won't access the data in the database.
What I'd like is to write a little PHP to access the database and echo HTML in the iframe, then be able to call that with a parameter that tells it which record to access. (This could be a POST or a GET.) I'd like for the user to be able to push a button or click a link and load the iframe with the proper code from the database. Is this possible? Are there other solutions than using an iframe for this? I could call back to the same page with the parameter, but that reloads the whole page, which I'd prefer not to do.
Thanks for any help you can give me!
Logged
Ruud
WebsiteBaker Org e.V.
Offline
Posts: 2297
Re: Accessing SQL from iframe on code page
«
Reply #1 on:
January 28, 2011, 10:29:57 AM »
The problem is that a single php page will not have the WB framework loaded, so you will not be able to use the objects (like $database) in there.
A solution would be to create a blank template (just the page_content() call) and link that template to the codepage you created.
You should be able to use that output in your iframe.
Logged
Professional WebsiteBaker Solutions
richwingerter
Offline
Posts: 4
Re: Accessing SQL from iframe on code page
«
Reply #2 on:
January 29, 2011, 12:41:15 AM »
Thanks for that suggestion. I have a couple more questions, then.
Can I create a blank template and still use the current one? Will I have to go through an installation or can I just reference a blank template from the page included in the iframe and leave the current structure in place?
BTW, you can see the current website at
http://www.greenmaking.com/index.php
. It uses a slightly modified mamboportal template. I'm trying to set up a place where I can view videos using the embedded code stored in the database. If there's a simpler way to do this (or just a better way...) I'd appreciate the help.
Thanks!
Logged
snark
Guest
Re: Accessing SQL from iframe on code page
«
Reply #3 on:
January 29, 2011, 09:50:05 AM »
The content for the iframe ... Is that a page created in the same installation as where the main page that holds the iframe? In that case you can possible also use the sectionpicker or the droplet that does nearly the same thing (showsection).
Logged
richwingerter
Offline
Posts: 4
Re: Accessing SQL from iframe on code page
«
Reply #4 on:
January 30, 2011, 07:25:52 AM »
I can create the page for the iframe either inside the Website Baker installation or outside it. To test it, I created a simple HTML page with static HTML code inside. This loads fine with a link that uses the iframe as a target. So, in the code within the Website Baker page, I can generate a link that loads the iframe:
echo '<iframe name="frame_name" src="http://.../blank.html" width="100%" etc.></iframe>';
later
echo '<a href="http://.../test_contents.html" target="frame_name">Test load</a>';
As long at the test_contents.html file is static HTML, it loads fine.
What I want to do is to have the page loaded into that iframe be PHP code that accesses my database and shows contents depending on what I ask it to do. So, for example, I should be able use:
echo '<a href="http://.../real_contents.php?item=1" target="frame_name">Test load</a>';
to have the real_contents.php page look up record 1 and display contents from it.
If I use a page generated from Website Baker (by adding a code page and making it the href in that link), then it loads the header, footer, and so on. Ruud suggested that I use a blank template. I'm not clear how to use two different templates in the same installation, but when I figure that out I will try that.
Thanks for your suggestions. I'll look into them.
Logged
richwingerter
Offline
Posts: 4
Re: Accessing SQL from iframe on code page
«
Reply #5 on:
January 30, 2011, 09:00:00 AM »
I was able to get the code to load properly and fill the iframe. Here were the gotchas:
The code I wrote used an HTML page where the PHP was embedded using "<?php" and "?>" tags. I put the code into an x.html file. This appeared to run okay outside the Website Baker context (or perhaps I changed the file name when I put it into place.) Also, the PHP code itself had references to objects, such as "$mydb->connect()", which is where it started to show code.
When I tried to load this into the iframe with a link and target, it didn't run the PHP interpreter on it (apparently because of the ".html" extension). This meant that it thought it was getting pure HTML, so when it got to the first ">" symbol inside the PHP code, it ended what it thought was a tag and started putting out the rest as literal HTML.
I first changed the "<?php" to '<script type="text/php">' to see if it interpreted this differently. This did not drop out at the ">" symbol. It still interpreted this as HTML, but that gave me the clue that it wasn't running PHP on the page.
So, I changed the extension from ".html" to ".php". When I did this, the PHP stated to run. Since this results in a pure HTML page (after PHP finishes), then I got what I wanted in the iframe, because it doesn't surround it with headers and sidebars and such.
Thanks for your suggestions, which kept me going.
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...