Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
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
Re: Retrieving prefs values without a plugin
Offline