![]() |
Use PHP to show page identified by URL parameters?
Hello, I've never really used PHP before, and I'd like to know how to load pages into an iframe depending on a url parameter. (I am doing this now with JS, but it is slower, and creates problems for SEO and those with JS disabled.)
I'd like to have the iframe source and page title set server-side into my template page. Thanks! :D |
PHP Code:
|
Thank you! :thumbsup: Just a couple more questions:
How do I set a default iframe source if the url specified by the parameter, or the parameter, is missing? How can I pull the title of the page from the iframe and echo it here? How do I change any uppercase letters in the parameter to lowercase? Thanks! |
PHP Code:
|
Thanks again! However, the parameter default page is not working. I just get a PHP error saying "implode() : Invalid arguments passed" Thank you!
|
It works fine. Just comment out the test URL and place it in the default field. I'm guessing you just left it as "someDefaultPage.php".
PHP Code:
|
Quote:
|
It will work with HTML files, yep :thumbsup:
|
I see now better how echo is essentially a server-side variable. What I have:
<iframe src="http://example.com/A/B/<?php echo $url; ?>.html"></iframe> However, the PHP is passing urls of pages that don't exist. How can I fix this? Also, the only thing $title that ever shows is someDefaultTitle.Thank you! :D |
The page will accept 'any' value in the url variable at the moment. You need to validate your data first. For instance, you might use
file_exists() to check whether the page exists in your directory, and if not refer to the default page.The title works for me. Are you sure that your pages actually contain titles? PHP Code:
|
Quote:
directory/filename.html. I would like to just be able to set the filename in the URL. Thank you! :D |
PHP Code:
|
Still not working. :( If I'm not getting a PHP error, the file_exists is returning as negative. Thank you!
|
Please don't tell me you've left the directory as
someDirectory/??? |
Quote:
PHP Code:
|
| All times are GMT +1. The time now is 09:03 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.