--------------------------------
Title
--------------------------------
Relative URLs for XSLT Page Templates
--------------------------------
Description
--------------------------------
I’ve been wondering how best to create HTML output with links using relative URLs. There are a number of discussions about how best to redirect internal links in XML content:
### Absolute URLs for XML content
* [Redirecting internal links to $root URL with xsl:apply-templates](http://symphony-cms.com/forum/discussions/152/1/)
* [Relative/abs linking in text areas in multiple environments](http://symphony-cms.com/forum/discussions/485/)
* [Resolve a parameter in XML content](http://symphony-cms.com/forum/discussions/20680/)
* [Format relative URLs](http://symphony-cms.com/downloads/xslt/file/24197/)
But how can I create relative URLs instead? I [posted this question](http://symphony-cms.com/forum/discussions/24637/) on the Symphony CMS forum.
--------------------------------
Body
--------------------------------
### Relative URLs for XSLT Page Templates
So, in Symphony CMS, I want to produce URLs that look like this:
rather than this:
What I have yet to see is how to create relative URL structures for a site. For example, I could have a page that has the following URL parameters:
a/b/c/d/e/f
My first thought would be to determine what the currently selected level is, then set the relative root string:
0
6
5
4
3
2
1
0
./
../
../../
../../../
../../../../
../../../../../
../../../../../../
Or, I could skip the separate test for the current level and do both with a single parameter:
../../../../../../../
../../../../../../
../../../../../
../../../../
../../../
../../
../
./
When packaging the files for the Fluid Grid System, I ended up building the pages in Symphony, but had to edit each individual file, using a search-and-replace function in a text editor, to produce the HTML demo with relative URLs. This is less than ideal.
My solution lacks some flexibility, though, since, for every page that uses a different set of URL parameters, this template needs to change to test for the correct sequence of URL parameters. This would require a different master template for every page where the URL parameters are different, negating the usefulness of a master template. Is there a more flexible way to do this? Perhaps, the answer for this scenario is to always use the same sequence and names for URL parameters and be sure that the data source filtering references these parameters.
--------------------------------
Date
--------------------------------
14 Jul 2009 2:07pm
--------------------------------
Section
--------------------------------
Journal
--------------------------------
Category
--------------------------------
Technology
--------------------------------
Tags
--------------------------------
symphony cms, xslt