Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-08-21 11:39:29

fyankai
Member
Registered: 2008-07-07
Posts: 22

Linking to TXP root when TXP is in subdirectory (eg "/css/...")

Hi All

I’m trying to move my TXP site from my local server onto a host’s one. I’ve managed to move the DB across, and got the basics working. However, the links to CSS and JS files have stopped working, I think because they use “/css/…”, while TXP is installed in a sub-directory (while I’m testing it).

My settings go something like this:

Site URL in Preferences is tallstories.org.uk/test

and in config.php I’ve got:

$txpcfg[‘txpath’] = ‘/www/test/textpattern’;
$txpcfg[‘doc_root’] = ‘/www/test/’;

which seems to be right as TXP is basically working; it’s just not treating “tallstories.org.uk/test” as the root when I ask for “/css/…” or “/scripts/…”.

Is there a setting I’m missing? I could obviously write all urls as absolutes, but there are a lot of them, and I’d have to rewrite them again when I move TXP from /test to the root directory.

Many thanks any help

Frank

Offline

#2 2008-08-21 12:33:41

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Linking to TXP root when TXP is in subdirectory (eg "/css/...")

<txp:site_url /> would probably help, like so:

<script type="text/javascript" src="<txp:site_url />js/jquery.js"></script>

For style sheets, Txp can handle all the CSS itself.

Offline

#3 2008-08-21 12:45:07

fyankai
Member
Registered: 2008-07-07
Posts: 22

Re: Linking to TXP root when TXP is in subdirectory (eg "/css/...")

I kind of prefer having all the CSS separate – so I can build sites first in HTML then convert them over, and so I can tweak it with FF Web Developer after.

<txp:site_url /> would work for calling scripts/css in the header, but won’t help with background images in the css – I’ve got a lot of them and they all start background:url(“/images/_siteImages/…

Is there not an easy way to make TXP treat the subdirectory it’s running in as the root for these links? It seems strange that you should have to make all urls absolute.

Or is there something you can put in a .htaccess file in the subdirectory that would make TXP treat it as the root dir?

Thanks, Frank

Offline

#4 2008-08-21 12:51:30

juanjonavarro
Plugin Author
From: Valencia, Spain
Registered: 2005-05-16
Posts: 485
Website

Re: Linking to TXP root when TXP is in subdirectory (eg "/css/...")

The url in a CSS are relative to the CSS. So, if your CSS is in “css” folder, you can put rules as:

background:url(”../images/_siteImages/…

Offline

#5 2008-08-21 12:58:51

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Linking to TXP root when TXP is in subdirectory (eg "/css/...")

The BASE element allows authors to specify a document’s base URI explicitly.

Links in HTML documents

Offline

#6 2008-08-21 13:38:52

fyankai
Member
Registered: 2008-07-07
Posts: 22

Re: Linking to TXP root when TXP is in subdirectory (eg "/css/...")

juanjonavarro: that’s true, I didn’t think of that.

wet: I didn’t know about BASE elements – that’s handy, thanks.

I can make it work with these two combined, but I’m still a bit surprised that TXP doesn’t have a way of setting whatever folder you want as the root. Lots of people must use “/css/…” and “/scripts/…” etc, so it seems strange that you can’t here. Ho hum.

Thanks for all your help

Offline

#7 2008-08-21 13:47:49

juanjonavarro
Plugin Author
From: Valencia, Spain
Registered: 2005-05-16
Posts: 485
Website

Re: Linking to TXP root when TXP is in subdirectory (eg "/css/...")

fyankai, I don’t kwon exactly what TxP is supposed to do.

TxP is a system that:

  • Store the articles and other items (images, etc) in a database.
  • Gives you a system to “build” pages using the articles.

If you put this in a txp template:

<img src="/images/foo.gif"/>

This is exactly what you get. TxP assist you in creating pages you can move using the <txp:site_url /> tag. So you can write:

<img src="<txp:site_url />images/foo.gif"/>

But, if you don’t use it, TxP cannot “automagically” change the URL you write.

Offline

#8 2008-08-21 13:54:15

fyankai
Member
Registered: 2008-07-07
Posts: 22

Re: Linking to TXP root when TXP is in subdirectory (eg "/css/...")

Yeah that’s true. Thinking about it, your two solutions above will work well. Was just in a rush to get this to work so was hoping to find one magic setting somewhere that’d do everything!

Thanks for all your help

Offline

Board footer

Powered by FluxBB