tags:

views:

57

answers:

2

File structure is as follows:

index.php

settings/
|-manage_account.php

templates/viriditio-v2/
|-index.tpl

templates/virditio-v2/css
|-style.css

localhost/~braden/virditio/index.php shows the template like expected showing index.tpl with the style sheet paths correctly showing:

<link rel="stylesheet" href="templates/virditio-v2/css/style.css" type="text/css"/>

However localhost/~braden/virditio/settings/manage_account.php shows the same path, which is the relative path (should be ../ to be complete).

What's an easy way to make it relative to the template? Or absolute to the root? Is there a Smarty function that includes css files and makes them not relative?

Currently I have it set like this:

config: template_url = "templates/virditio-v2/"

and .tpl: <link rel="stylesheet" href="{#template_url#}css/reset.css" type="text/css"/>

EDIT

It's not pretty but I was able to accomplish it with

{assign var='config_url' value=#template_url#}
{assign var='template_url' value=http://`$smarty.server.SERVER_NAME`$config_url}

Any better solutions out there?

A: 

If I understood correctly the issue is to have a CSS file linked to a webpage no matter where in the folder tree the page comes from. This might be written as:

<link rel="stylesheet" href="/~braden/virditio/templates/virditio-v2/css/style.css" type="text/css"/>

This would make it a fixed path starting from the root of the server.

djn
Right, however I'm making a system that needs to be expandable and run on multiple hosting environments. That's why I'm trying to create it dynamically...
bradenkeith
A: 

Why not access the CSS like

/templates/virditio-v2/css/style.css

with an absolute path?

If its about different hosting environments in subdirectorys, consider a config option to set the base directory and append it as a vairable to the path in your smarty template.

JochenJung