Page 1 of 1
header/footer issue
Posted: Thu Oct 06, 2005 5:22 pm
by <?php echo $php-addict
Hi,
I am using header/footer style design. The problem is when I set a folder called "includes" and have the header.php and footer.php outside of that directory.
inside "includes" I have a page called bookings.php:
Code: Select all
require '../header.php';
code
require '../footer.php';
now the images url for the grahics in header/footer.php gets set to:
http://www.blabla.com/includes/images/image.jpg
rather than
http://www.blabla.com/images/image.jpg
as it should be .. So any file within the includes folder doesnt show the graphics from within header/footer.php when called on.
How is that corrected, as I have files within other folder as well to keep the server clean and files easy to locate ..
Thank You
Posted: Thu Oct 06, 2005 5:51 pm
by Luke
inlcude a file on all pages with a $dir variable that will be the directory where those pics are stored
For example:
Code: Select all
$dir = "http://www.blabla.com/images";
Now use this when you want to display an image or whatever:
Code: Select all
<img src="<?php echo $dir."/image1.jpg" ?>"
Posted: Thu Oct 06, 2005 6:47 pm
by <?php echo $php-addict
Hi,
Its more the complete website graphic that has been sliced ..
I used to use an index page with action "switch" with "case", but thought it would be cleaner just linking to the actual pages rather than functions for ease of adding page titles etc.
How do others go about it, I thought tht with it calling the images from include folder was out of order as the link to the images with in header footer link to /images not /includes/images.
How do other stucture this type of layout?
Thank You
Posted: Fri Oct 07, 2005 1:28 pm
by Skara
I have my photography site as so (truncated):
Code: Select all
photography:
blog.php bota.php contact index.php logout mia.php mibb.php register styles top.php
bot.php conf.php functions.php login lord-of-frogs mib.php photos script.php terms.php usercp
photography/contact:
index.php
photography/login:
forgot_password.php index.php
photography/logout:
index.php
photography/admin:
[admin pages]
photography/photos:
bak.view_category.php comments.php files index.php rateme.php select_category.php view.php view_cat.php view_image_a.php view_image_b.php
photography/photos/files:
[images] prevs_lg prevs_sm
photography/photos/files/prevs_lg:
[large thumbs]
photography/photos/files/prevs_sm:
[small thumbs]
photography/register:
confirm.php index.php
photography/styles:
default
photography/styles/default:
[site images] style.css
photography/usercp:
index.php
where top, bot, mia, mib, mibb, and bota are sorta like your header files. Then whenever I have an image in the style, I'll do:
Code: Select all
$HTML .= "<img src='/styles/".STYLE."/image.jpg' alt='example' />"; // where STYLE is defined as a folder name
The trick is the leading /. I use top.php in every page. So..
Code: Select all
# /index.php
require('top.php');
# /photos/index.php
require('../top.php');
And the images work fine in each. If, on the other hand, I left out the leading slash, it would try to load as so:
Code: Select all
<img src='styles/default/image.jpg' />
would load /photos/styles/default/image.jpg, but
<img src='/styles/default/image.jpg' />
will always load /styles/default/image.jpg
I probably gave you too much info, but you asked how other people had things set up. ^^;