Page 1 of 1

absolute paths

Posted: Tue Jun 02, 2009 2:41 pm
by RobDraw
My directory is something like this:

root
../members
../includes
../includes/column
../includes/column/modules

in root i include in the index.php
<?php include "includes/column/right_column.php";?>

the right_column.php also includes various modules like so:
<?php include "includes/column/modules/right_col_yog.php";?>

which basically populate a column on the webpage.

So far this works ok.

My problem is when i want to include the same module/s in a file in the members directory.

I can call
<?php include "../includes/column/right_column.php";?>
Which finds the file "right_column.php", but it dosent find the includes in this file like "right_col_yog.php".

I realise the problem maybe due to using relative path but I am wondering to write absolute paths for this problem and if it is solvable.

Any pointers

Re: absolute paths

Posted: Tue Jun 02, 2009 2:49 pm
by mikemike
Just define a path in a config file with your absolute path in it:

Code: Select all

$include_dir = '/var/www/vhosts/example.com/httpdocs/';
Then use it in all your includes

Code: Select all

include($includes_dir.'includes/modules/columns/right_col.php');
..or just add it into your include dir's in your php.ini

Re: absolute paths

Posted: Tue Jun 02, 2009 3:32 pm
by RobDraw
Thank You.