/    Sign up×
Community /Pin to ProfileBookmark

PHP to replace iframes

Is there a way to use a php script to replace an iframe page? I would like to call content into different parts of the page while other parts stay constant. I haven’t designed in years and I’m trying to get back into things and learn new ways of developing.

Thanks,
Stacey

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@dbrandonJul 24.2007 — Yes, you could use includes to replace the 'sub pages' that would have been in the iframe.

Design your 'main page' (which the content will be added into). All aspects on this page will be constant. Then use

[code=php]include('path/to/sub/page.html');[/code]

to 'pull' the content from another page.

You'd want to assign a variable (probably url) to control the included content.

A simple way to do this would be to use the code

[code=php]include($_GET['page']);[/code]

at some point in your main file (lets say its called index.php). Then, you can control the included page through the url. index.php?page=subpage.html for example. In this case, the content of index.php would be displayed, up until the 'include' then the content of subpage.html would be displayed, followed by the rest of index.php.

You should write a bit of code to check that the requested include is 'allowed'. You wouldnt want people including other pages on your server.
Copy linkTweet thisAlerts:
@ellisglJul 30.2007 — "include($_GET['page']);"....

I would totally not recommend doing that!

Also look up CURL / Snoopy
Copy linkTweet thisAlerts:
@TadyBauthorJul 30.2007 — Thanks so much for your suggestions. I will be researching more and trying them out soon.
Copy linkTweet thisAlerts:
@BeedgeJul 31.2007 — I dont think that iframes and php includes are the same thing at all.

for an include to work the whole page is going to have to be refreshed and served as HTML. Once it gets to the browser it will be a complete HTML page.

Where as to poulate an iframe with content you will only need to refresh that particular frame while the rest of the page remains the same
Copy linkTweet thisAlerts:
@ellisglJul 31.2007 — it all depends on what he's doing.
Copy linkTweet thisAlerts:
@EridiusJul 31.2007 — including a file is not the same as an iframe, not even close. I would look into javascript to replace these even tho i would personally find a way of doing tou you are trying to do, whatever that maybe, without doing something like iframes(depending on what your are doing AJAX might work).
Copy linkTweet thisAlerts:
@ellisglJul 31.2007 — Is there a way to use a php script to replace an iframe page?[/QUOTE]
That was the original question.

The answer would be to CURL it and echo it out. But it all depends on what the iframe page is containing. If it has to deal with $_SESSION or external Links - then this would not be the way to it.
Copy linkTweet thisAlerts:
@TadyBauthorJul 31.2007 — This is the site:

http://www.gotechcomputing.com/keils/index.html

The left nav iframe calls a photo gallery into the center iframe according to the link selected. Only the bracelets and earrrings links work as of now.
Copy linkTweet thisAlerts:
@ellisglJul 31.2007 — Are you planing on a shopping cart - or just a web photo gallery?

Oh there are issues with firefox with the left nav.
Copy linkTweet thisAlerts:
@TadyBauthorJul 31.2007 — Nope, no shopping cart...just a gallery. I had it working in FireFox earlier and have made a few edits since...I've must have done something it doesn't like. I'm at the point where I'm very willing to scratch everything I have and start over using a better method if you have suggestions on what I should use. I pretty new to php and other scripting methods, but I learn quickly.

Thanks!
Copy linkTweet thisAlerts:
@ellisglAug 01.2007 — I would just head over to hotscripts and look up picture galleries.. There are a ton of them out there.
×

Success!

Help @TadyB spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...