Solved

Finding the root Link

Posted on 2008-09-29
7
231 Views
Last Modified: 2013-12-13
I'm having a bit of trouble geting my head arround relative links.
I use a template in dreamweaver which points to a file, within a php function" named "../../Community/NewsRss/Google_Feed.xsl" .
Now if the template is used in a file which is located in the /NewRSS folder it can read the XML file, however if it is in the root folder I get the message "The specified file ../../Community/NewsRss/Google_Feed.xsl could not be found."

I would have thought that ../../ would work where ever.
Any clues to where I am going wrong.
0
Comment
Question by:Simon Cripps
  • 4
  • 3
7 Comments
 
LVL 29

Expert Comment

by:fibo
ID: 22600910
If you are using "../../Community/NewsRss/Google_Feed.xsl" from within NewsRss... you could probably in that case use "Google_Feed.xsl" directly....

Now if you are using from 2 levels above, you should use instead "./Community/NewsRss/Google_Feed.xsl"

And if this "2level above" is also the home/root dir, then "/Community/NewsRss/Google_Feed.xsl" should be the link to use
0
 

Author Comment

by:Simon Cripps
ID: 22601209
Part fixed, part broke.
If I use "./Community/NewsRss/Google_Feed.xsl" in the template then files in the root directory are able to read the file but not in the NewsRSS folder.
However for this to work on files in the NewsRSS folder I need to change the template to "../../Community/NewsRss/Google_Feed.xsl" .
The problem is that as this for two pages, in different folders, using the same template I have to use one or another. Do you know why "./" works in the root folder and "../../" NewsRSS folder.
0
 
LVL 29

Expert Comment

by:fibo
ID: 22603470
- Just to be sure: is it NewsRSS or NewsRss? Unix is case sensitive, while it does not matter under Windows

- The path thing.
It depends on where you are.
-- If you are in the root folder, then 'mydir', './mydir' and '/mydir' all point to the same place.
-- If you are in /mydir folder, then 'mydir1', './mydir1', '/mydir/mydir1' and '../mydir/mydir1' all point to the same place.

When the address start with / then this is an "absolute" address and is given relative to the root
In all other cases the adress is relative to the current directory, for which the conventional shortcut is a single dot '.'
The 'father' directory of the current directory is conventionally '..'

This is why it is coherent that in root "./Community/NewsRss/Google_Feed.xsl" works fine while in directories 2 levels under, such as NewsRss you need '../../' (to go up 2 levels).
What happens when you use in both situations "/Community/NewsRss/Google_Feed.xsl" ?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Simon Cripps
ID: 22607817
All makes complete sence, but does not appear to work. if I use  "/Community/NewsRss/Google_Feed.xsl" then the error appears in the pages in both locations.
So I still need to refer to ./Community/NewsRSS/ folder in root and ../../Community/NewsRSS/ from the NewsRSS folder.
Could it be because these are being defined in PHP?
0
 
LVL 29

Accepted Solution

by:
fibo earned 500 total points
ID: 22609794
<<Could it be because these are being defined in PHP?>>
I think this is not specific to PHP.

When you are in .../NewsRss/, what happens if you address the file as "./Google_Feed.xsl"?

I remember I once had a similar problem, and the workaround to have a "clean" code was to compute the directory prefix directly from the script location, eg using predefined variable __DIR__
0
 

Author Closing Comment

by:Simon Cripps
ID: 31501371
This may also be as I am using the parameter in dreamweaver MM_XSLTransform() rss reader. as this does not affect any other of my links in the template. I now set the directory in the editable area at the top of the template so I can change it for each page
0
 
LVL 29

Expert Comment

by:fibo
ID: 22610458
B-)) glad this is solved. Thx for the points and grade
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now