Newbie question about root folder w/php

  • fonsy2000
  • Novice
  • Novice
  • User avatar
  • Joined: Sep 03, 2006
  • Posts: 24
  • Status: Offline

Post September 5th, 2009, 6:51 pm

Hi,

I just reorganizing the website and I found the problem loosing the root folder in some page, so, I get some pages that doesn't show correctly loosing the background path.

The problem is that I want to have 1 folder for all images and css, everything work good until I call the images and the css from another folder that is not the root, when I try ../ some of the pages work and other not



Would somebody here can help me?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 5th, 2009, 6:51 pm

  • ben_sigma
  • Beginner
  • Beginner
  • User avatar
  • Joined: Mar 12, 2008
  • Posts: 58
  • Loc: South Australia
  • Status: Offline

Post September 7th, 2009, 1:12 pm

all ../ does is return one level. so heres a scenario;

Directory----------Need to access----------From

root/car.jpg--------------------car.jpg---------------------root
../car.jpg----------------------car.jpg------------------root/page1/
../../car.jpg--------------------car.jpg--------------root/page1/includes/

I hope this makes sense and helps. If not reply and i will attempt to clarify.
  • fonsy2000
  • Novice
  • Novice
  • User avatar
  • Joined: Sep 03, 2006
  • Posts: 24
  • Status: Offline

Post September 10th, 2009, 1:12 pm

sorry, but is not that I am looking for, let me try to explain again;

I have index.php in root, where the index is divided by header.php and footer.php
Inside of header and footer I have images, css and links
When I call index.php those file open and work well, but when create any other file in any of the subfolder root/folder1/page2.php and use the same header and footer, the links and some others files don't work.
The think that I am trying to find is a function in php or class that can solve this problem.

Thank you for you answer

Any other comment?
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Joined: Jul 25, 2005
  • Posts: 2735
  • Loc: Nashville, TN
  • Status: Offline

Post September 10th, 2009, 2:42 pm

Have you considered reworking your organization? The issue lies in how you're requiring/including your code. Your working directory is most likely swapping to the file that's calling upon the header and footer. If you rethink your organization to something like what's below, they your templates are all in one location and your calling files are all in one location, so any includes of a template should work the same.

index.php
file1.php
file2.php
templates/header.php
templates/footer.php
images/img1.jpg
images/img2.jpg
I'd love to change the world, but they won't give me the source code.
  • fonsy2000
  • Novice
  • Novice
  • User avatar
  • Joined: Sep 03, 2006
  • Posts: 24
  • Status: Offline

Post September 16th, 2009, 8:02 am

ok, but I have links inside header and footer files that point to root, so, when I use this header/footer files on other folder that is not root, the link don't work, how can I solve this using a php function.

Thank you for your help

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 100 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.