[SOLVED] including dynamic pages
Moderator: General Moderators
including dynamic pages
Hi All,
I have set up a page that reads a thumbnails directory and then displays the thumbnails on the page. This script reads the /thumbnails directory.
If I try to include this file on another page somewhere else it errors out because there isn't a thumbnail folder in the directory that runs the parent script.
What is the best method for doing something like this?
Brad.
I have set up a page that reads a thumbnails directory and then displays the thumbnails on the page. This script reads the /thumbnails directory.
If I try to include this file on another page somewhere else it errors out because there isn't a thumbnail folder in the directory that runs the parent script.
What is the best method for doing something like this?
Brad.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Hi Phenom.
My problem occurs when I have the thumbnails.php in different folder to the main script that it is included on.
Example:
index.php is in the www directory.
thumbnails.php is in the www/clients/smith directory.
There is no /thumbnails folder in the www directory so when the index.php script runs and has the thumbnails.php script included on it, the thumbnails.php searches the www directory for a thumbnails folder.
Does that make sense?
Brad.
My problem occurs when I have the thumbnails.php in different folder to the main script that it is included on.
Example:
index.php is in the www directory.
thumbnails.php is in the www/clients/smith directory.
There is no /thumbnails folder in the www directory so when the index.php script runs and has the thumbnails.php script included on it, the thumbnails.php searches the www directory for a thumbnails folder.
Does that make sense?
Brad.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
OK.
It is sort of working. The only problem now is that the thumbnails.php has an included style which doesn't work.
<link href="../../styles/image_gallery_styles.css" rel="stylesheet" type="text/css" />
If the thumbnails.php is included on the index.php it searches back 2 directories from the folder that the index.php is in...which isn't possible.
Do you know how to rectify this?
It is sort of working. The only problem now is that the thumbnails.php has an included style which doesn't work.
<link href="../../styles/image_gallery_styles.css" rel="stylesheet" type="text/css" />
If the thumbnails.php is included on the index.php it searches back 2 directories from the folder that the index.php is in...which isn't possible.
Do you know how to rectify this?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
you can set it up to automatically switch when you move to the live server using $_SERVER['HTTP_HOST'] or other environment information...
Code: Select all
<link href="/web/viewable/path/from/document/root/whatever.css" rel="stylesheet" type="text/css" />feyd wrote:you can set it up to automatically switch when you move to the live server using $_SERVER['HTTP_HOST'] or other environment information...
Code: Select all
<link href="/web/viewable/path/from/document/root/whatever.css" rel="stylesheet" type="text/css" />
Do you know how I do this? I thought you might just put something like the following as the styles link but that doesn't work.
Code: Select all
<link href="<?$_SERVERї'HTTP_HOST']?>/styles/image_gallery_styles.css" rel="stylesheet" type="text/css" />- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
something more like:although I'd suggest using a template system/engine set up.
Code: Select all
$site_root = $_SERVERї'HTTP_HOST'] == 'localhost' ? '/devroot' : '/liveroot';Code: Select all
<link href="<?php echo $site_root ?>/web/viewable/path/from/document/root/whatever.css" rel="stylesheet" type="text/css" />I understand the include part of your suggestion feyd. What is the above line actually doing? The "==", ? and : are throwing me...but I'd really appreciate you helping me understand.feyd wrote:something more like:Code: Select all
$site_root = $_SERVERї'HTTP_HOST'] == 'localhost' ? '/devroot' : '/liveroot';
Thanks.
Uhm....can I kiss you?feyd wrote:expression1 == expression2
returns true if expression1 is equal to expression2
expression1 ? expression2 : expression3
evaluates expression1, if it returns true, expression2 is returned; otherwise, expression3 is returned.
Thank you so much. I implemented the following:
Code: Select all
<? $site_root = $_SERVER['HTTP_HOST'] == 'localhost' ? '/TestServer/RootFolder/styles' : '/styles'; ?>
<link href="<? echo $site_root ?>/image_gallery_styles.css" rel="stylesheet" type="text/css" />Thankyou so much for your help with this feyd. Your patience is so much appreciated.
Brad.
And let me do some little change 
Use
Instead
make use of the <?=$somestringvar?>
Use
Code: Select all
<link href="<?=$site_root ?>/image_gallery_styles.css" rel="stylesheet" type="text/css" />Code: Select all
<link href="<? echo $site_root ?>/image_gallery_styles.css" rel="stylesheet" type="text/css" />