Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-09-19 19:50:00

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

What do you use txp:site_url for?

Just wondering what clever uses others have found for the txp:site_url tag.

I had figured, it’s really helpful for coding a site’s main navigation links e.g. <txp:site_url />/about/ in case you later need to move the site to a different directory like to a local dev server where it lives in a subdirectory. Then you can just update the site’s url in the prefs and it all works.

But are there other scenarios, where the tag comes in handy?
The Textbook example doesn’t make much sense to me.

Offline

#2 2009-09-19 21:20:43

TNT
Member
From: Rotterdam, Netherlands
Registered: 2006-01-06
Posts: 256
Website

Re: What do you use txp:site_url for?

I use it in <head>...</head> for linking to external css and javascript files. That way, these files are always found, no matter what page you’re on.


Prrrrrrrr

Offline

#3 2009-09-19 21:49:40

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: What do you use txp:site_url for?

masa wrote:

I had figured, it’s really helpful for coding a site’s main navigation links e.g. <txp:site_url />/about/ in case you later need to move the site to a different directory like to a local dev server where it lives in a subdirectory. Then you can just update the site’s url in the prefs and it all works.

That’s the main purpose of the tag I guess, though your example would still get you into trouble if you’d ever have to change from clean to messy URLs. Using <txp:section name="about" link="1" title="1" /> would take care of that too, though it won’t let you customize your html output. This:

<a href="<txp:site_url /><txp:section name="about" />/" title="Visit my <txp:section name="about" title="1" /> page"><txp:section name="about" title="1" /></a>

would allow you to move your site, and change your section title, but not to switch to messy URLs.

Like TNT, I’m using it to point to .js files as well. Use it anywhere where you would otherwise hardcode the domain URL.

Offline

#4 2009-09-19 21:58:38

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: What do you use txp:site_url for?

I use it everywhere. Its much easier to move sites or change locations at a later date.

Offline

#5 2009-09-19 23:58:49

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: What do you use txp:site_url for?

Els wrote:

That’s the main purpose of the tag I guess, though your example would still get you into trouble if you’d ever have to change from clean to messy URLs.

Good point regarding messy urls.

Jonathan wrote:

I use it everywhere. Its much easier to move sites or change locations at a later date.

Yes, as you all mentioned, using it wherever such references are coded makes sites easily portable. Perhaps someone could update the Textbook entry to stress that.

Offline

Board footer

Powered by FluxBB