Page 1 of 1

<? include () ?> statment and similar

Posted: Thu Sep 21, 2006 5:56 pm
by m-a-s.it
Dear all,
I'm developping my own website and I'm also a beginner althought I've already implemented few structures by my own.

At the moment I'm having a problem.

My idea is to change a frame website structure with a php structure "including" single .php files and I'm also trying to translate from italian language to at least english.

the point is: using a frame structure, the relative path for all the links are related to the position of each single file. Instead, when i use the statment "include" the relative path change accordingly to the position of the including file with all links that will not work!

can you suggest me something? how can i "fix" the path even including different files? using an other instruction or?!
javascript:emoticon(':roll:')
Rolling Eyes

thanks in advance for any help!

ciao

mauro

Posted: Thu Sep 21, 2006 6:02 pm
by feyd
Don't use frames. Simple enough.

Posted: Fri Sep 22, 2006 4:03 pm
by m-a-s.it
exactly what I'm trying to do but what about my problem with include?
how do I fix an absolut path relative to the included file position even if the file is included wher else in the site web?

thanks

mauro

Posted: Fri Sep 22, 2006 4:15 pm
by feyd
I think you're confusing a few things here. An absolute path is the same wherever you are on the given server. A relative path must change depending on where you currently are. Absolute paths in unixland start with "/"

$_SERVER['DOCUMENT_ROOT'] may be of interest. On some server's it doesn't exist, so dirname(__FILE__) or getcwd() may also be of interest too.

refine my idea with include function!

Posted: Sun Sep 24, 2006 4:19 pm
by m-a-s.it
I've thought about a solution but still not working due a bad knowledge of php. please clarify!

I define, in the mail file calling the file to include a constant
<? define('PATH','./') ?>

whilst the included file seams like this:
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td height=75 colspan=7 align=center valign=top><div class=titolo>Benvenuti a bordo</div>
<span class=sottotitolo>Il ciber-viaggio sta per cominciare!</span></td>
</tr>
<tr>
<td width=15></td>
<td width=40% height=20 align=LEFT class=links> | <a href=PATH.guestbook/guestbookindex.php target=_parent> etc etc

but I don't know how to make the browser read the expression
<a href=PATH.guestbook/guestbookindex.php
as
<a href=./guestbook/guestbookindex.php

is it feasible, firs of all this way of use of php?
if yes, how I have to use the php tag or code?

if it works, in any main file I can define different value of path and meanwhile still using the same included code that will follow the instruction given by the constant value

if you have any idea or suggestion, please tell me!

cheers

mauro

Posted: Sun Sep 24, 2006 4:46 pm
by feyd
The posted content is of a very different variety than standard pathing. For the most part, you should only need a leading "/", not "./" as those are URL based references which work differently than file system pathing.

If the files are located at http://somesite.com/your/path/to/a/file.php, your links can normally be "/your/path/to/a/file.php" and they'll work just fine.