Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2025-09-27 19:17:12

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,502
Bitbucket GitHub

Retrieving prefs values without a plugin

I have a vague recollection there’s an unsupported (?) way of retrieving a txp_prefs value (val) from the corresponding name without need for a plugin.

I’d be most grateful if anyone could a) tell me if I’m imagining this, and – if not – b) let me know how to do it. A pointer to a previous thread would be perfect. Thank you very much.

Offline

#2 2025-09-27 19:31:55

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,031
Website GitHub

Re: Retrieving prefs values without a plugin

You can get a few with page_url but other than that, I’m not sure.

If you have php allowed in your articles/templates, you can use txp:php to do:

<txp:variable name="myvar" trim>
<txp:php>
   echo get_pref('prefname', 'default-response');
</txp:php>
</txp:variable>

<!-- output later -->
<txp:variable name="myvar" />

If you want to output it straight away, you can add the output attribute to txp:variable, or simply skip making it a variable altogether.

_______ <- space for Oleg or Stef to add the ultimate solution :-)


TXP Builders – finely-crafted code, design and txp

Offline

#3 2025-09-27 19:35:40

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,502
Bitbucket GitHub

Re: Retrieving prefs values without a plugin

jakob wrote #340711:

If you have php allowed in your articles/templates, you can use txp:php to do:

Perfect – I’ll do this – thank you so much, jakob.

_______ <- space for Oleg or Stef to add the ultimate solution :-)

Exactly what I was thinking!

Offline

#4 2025-09-27 19:57:08

etc
Developer
Registered: 2010-11-11
Posts: 5,502
Website GitHub

Re: Retrieving prefs values without a plugin

Just to say something: if you only need to test a pref value, this should help (but requires php privs):

<txp:if_request type="system" name="lastmod" match=">" value="2025">
    staying alive
</txp:else />
    comfortably numb
</txp:if_request>

Offline

#5 2025-09-27 20:17:33

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,502
Bitbucket GitHub

Re: Retrieving prefs values without a plugin

etc wrote #340716:

Just to say something: if you only need to test a pref value, this should help (but requires php privs):

Wonderful – thank you very much, etc.

jakob wrote #340711:

_______ <- space for Oleg or Stef to add the ultimate solution :-)

Not even 30 minutes later!

Offline

Board footer

Powered by FluxBB