Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2024-09-03 19:29:01
- Adams
- Member
- Registered: 2024-08-30
- Posts: 34
custom fields
Is it possible to use custom fields for something other than articles? like site related value.
Thanks
Offline
Re: custom fields
Not at the moment, sadly. It’s planned.
For other content types, check out the repositories of jools-r who has kindly written plugins to add custom fields to other content types and locations.
If you’re after site-wide “constants” then you can build those yourself in a Form by setting a series of <txp:variable>
tags and including that form on every page via <txp:output_form>
. It’s not ideal, though.
The other option is to write a tiny plugin to add your own ‘prefs’ area to the Admin>Preferences panel and a corresponding tag to access the stored values but it really depends on what and where you want to use the field values.
I had a plugin once that did something like that but I can’t for the life of me remember what it’s called and I’m away from my laptop at the moment.
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 2024-09-03 21:13:43
- Adams
- Member
- Registered: 2024-08-30
- Posts: 34
Re: custom fields
Thanks,
It will be nice to have a few extra custom fields site-wide that can be used for anything.
Offline
Re: custom fields
Adams wrote #337776:
It will be nice to have a few extra custom fields site-wide that can be used for anything.
That’s not quite the case (something along those lines is slated for a forthcoming txp version) but there are individual custom field plugins for different cases – images, links, files, sections etc.
TXP Builders – finely-crafted code, design and txp
Offline
Re: custom fields
Bloke wrote #337771:
If you’re after site-wide “constants” then you can build those yourself in a Form by setting a series of
<txp:variable>
tags and including that form on every page via<txp:output_form>
. It’s not ideal, though.
That’s the simplest way. A plugin called “adi_variables” made a UI for this kind of setup so that you can setup your site-wide variables from the admin area. It’s great if you work just from the database, but if you load templates and forms from files, it runs into conflicts.
The other option is to write a tiny plugin to add your own ‘prefs’ area to the Admin>Preferences panel and a corresponding tag to access the stored values but it really depends on what and where you want to use the field values.
I had a plugin once that did something like that but I can’t for the life of me remember what it’s called and I’m away from my laptop at the moment.
I suspect it was oui_prefs or possibly the fabled smd_prefset? The oui_prefs plugin needs editing manually in the plugin code to set the variable names you want and input types, but then you get a panel on Admin › Preferences with inputs for entering site-wide variables that you access in your code using txp:variable. Works great and I routinely use an own version of this for site-wide variables.
One proviso: I suspect it won’t work if you use the ?f=formname
method discussed in the other post because if I’m not mistaken that bypasses the usual page setup routines that happen when textpattern serves a regular page, so the plugin will likely not automatically insert them as variables.
TXP Builders – finely-crafted code, design and txp
Offline
Re: custom fields
jakob wrote #337782:
I suspect it won’t work if you use the
?f=formname
method discussed in the other post because if I’m not mistaken that bypasses the usual page setup routines that happen when textpattern serves a regular page, so the plugin will likely not automatically insert them as variables.
Not tried, but it should. If memory serves, custom forms are processed in almost the same context that regular pages.
Offline
#7 2024-09-06 15:15:11
- Adams
- Member
- Registered: 2024-08-30
- Posts: 34
Re: custom fields
Thanks you,
Last edited by Adams (2024-09-06 15:16:11)
Offline
Pages: 1