Newbie question about root folder w/php

  • fonsy2000
  • Novice
  • Novice
  • User avatar
  • Posts: 24

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ben_sigma
  • Beginner
  • Beginner
  • User avatar
  • Posts: 58
  • Loc: South Australia

Post 3+ Months Ago

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
  • Posts: 24

Post 3+ Months Ago

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
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

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
  • fonsy2000
  • Novice
  • Novice
  • User avatar
  • Posts: 24

Post 3+ Months Ago

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 153 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
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.