Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2017-04-26 08:57:44

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

txp:site_url versus hardcoded URL

Is there any performance gain by using a hardcoded URL in a page/form template rather than tag such as <txp:site_url /> or <txp:section url="1" />? Does the CMS make a database call every time those tags are used in a template or just once then cache?

Offline

#2 2017-04-26 09:18:35

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,293
Website GitHub

Re: txp:site_url versus hardcoded URL

<txp:site_url /> just returns the site-wide constant, so all database wrangling has already been done: no additional overhead (bar the function call and parser itself).

<txp:section url="1" /> reads information from $thissection or the article context and then calls pagelinkurl(). That does further processing to return a formatted URL, including raising a plugin callback. So depending on the plugins installed, it could be more “expensive” in terms of raw computation and stack calls.

But neither tag makes any additional DB calls, as all the data they need has already been extracted.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2017-04-26 09:20:00

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: txp:site_url versus hardcoded URL

Great, thanks Stef!

Offline

Board footer

Powered by FluxBB