Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: [RFC] Custom Fields: expirable?
Your concept based on the expiry date of CFs is very interesting.
However, because future CFs creation will be unlimited, it could be confusing for users (writers)– the current case with the well known plugin– to see an interminable list of different CFs. For a better user experience, I think the most valuable feature will be based on sections, depending on CFs if they are relevant to the context (that’s your initial approach with the expiration dates, in part).
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: [RFC] Custom Fields: expirable?
And a short while later… (ahem, a yearish)… this commit marks the move towards unlimited custom fields for Txp 5.0.0.
Since the discussion above took place, a few changes have been implemented:
- Custom field creation and expiry now mimic the current 4.9.0 and below behaviour: by default, all custom fields are universally applicable to all content for all time.
- Two new checkboxes on the custom field management panel have appeared:
- Reset time to now: will set the publication date of the selected field to NOW when you save the changes. This permits a shortcut if you want to introduce a new custom field only available from this moment forward. Any other timestamp may be manually specified if you prefer.
- Set expiry now: will set the expiry date of the selected field to NOW when you save the changes. This permits a shortcut if you want to phase out a custom field and prevent people from using it in new assets created from this moment forward. Any other timestamp may be manually specified if you prefer.
- Front-end custom fields are wired up so you can display the stored custom field values. Access to more metadata (e.g. data type, default value, display order, family, etc) is possble but not yet wired up to the tags.
- Per-language custom field titles keep step with the changes to field names (in theory: needs more testing).
- Per-language custom field titles can be displayed on the public site by using the new
titleattribute to the<txp:custom_field />tag. Note that the language string displayed will always be in the current site language. There’s currently no provision for you to, for example, be showing a German site page and to grab English custom field titles from the database. - Varchars are now 7500 instead of 255 chars by default. That’s 7500 4-byte chars in utf8mb4, so potentially about 30KB if you’re storing mainly ASCII.
Next steps are to probably start rolling this out to other content types, panel by panel, and see how it holds up. And introduce a custom field iterator tag so you can loop over them instead of doing each one by hand. Watch this space.
Last edited by Bloke (2025-01-06 11:19:53)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: [RFC] Custom Fields: expirable?
Nice Stef ;)
Offline
Re: [RFC] Custom Fields: expirable?
Oh? Nice… Time to have a look again :-)
Does it already work with existing sites/databases or is that upgrading still on the todo list ?
Last time I tried, when accessing the login panel it still ran into a fatal mysqli error about missing tables or something (from memory).
Anyway, looking forward to this.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: [RFC] Custom Fields: expirable?
I don’t know how it handles upgrades right now. I’ve added a _to_5.0.0 file and moved all the table creation and field migration code there, but it probably won’t be triggered unless thisversion is increased. It won’t know we’re on the dev path towards it at the moment. Might be better to wait till 4.9.0 officially drops and we bump the version.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: [RFC] Custom Fields: expirable?
Bloke wrote #338680:
I don’t know how it handles upgrades right now. I’ve added a _to_5.0.0 file and moved all the table creation and field migration code there, but it probably won’t be triggered unless
thisversionis increased. It won’t know we’re on the dev path towards it at the moment. Might be better to wait till 4.9.0 officially drops and we bump the version.
That sounds good, we (I) can already play a little with a default install. Later this week when back home .
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Offline
Re: [RFC] Custom Fields: expirable?
I’ve just boosted the varchar storage limit to 7500. That’s about the maximum comfortable range given we need two columns (one raw, one textiled) per row, and is a worst-case limit if you entirely use 4-byte characters. Lesser character sets will be able to squeeze up to about 30KB in a field.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: [RFC] Custom Fields: expirable?
My goodness, that was easy. The system works! Image custom fields have landed
Just need to retrofit the tags so they can read the values.
Enjoy :)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: [RFC] Custom Fields: expirable?
Bloke wrote #338689:
My goodness, that was easy. The system works! Image custom fields have landed
Just need to retrofit the tags so they can read the values.
Enjoy :)
!!!!!!
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: [RFC] Custom Fields: expirable?
So far in some simple testing (creating & assigning CFs to Article and Image Content-type) this seems to work nicely.
Do I understand this correctly: A CF (any render type) with a created field filled cannot be used for content-type nodes created (or uploaded in case of an image) before the date set in the created field ?
Example: article created on 1/1/2025, the CF has the created field filled with 5/1/2025.
Still need to wrap my around the family field: that establishes some kind of grouping, I think and the default field (initial value, used if no value is specified when editing an article, or image ?).
Also, a thought: if the Help field is left blank (no help provided for that CF), does the pophelplink appear next to the CF? Currently it does, that sounds a little odd and confusing to me.
(I spent more or most time so far creating some content on that site)
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: [RFC] Custom Fields: expirable?
phiw13 wrote #338764:
So far in some simple testing (creating & assigning CFs to Article and Image Content-type) this seems to work nicely.
Excellent.
Do I understand this correctly: A CF (any render type) with a
createdfield filled cannot be used for content-type nodes created (or uploaded in case of an image) before the date set in thecreatedfield ?
Correct. And likewise the field will not appear if its CF expiry is set to a date after the content was created.
Still need to wrap my around the
familyfield: that establishes some kind of grouping, I think
You can use it for that, yes. But it’s not wired up to anything by default. Still deciding what (if anything) would make sense. At the moment the only way it can be used is via a plugin/theme.
the
defaultfield (initial value, used if no value is specified when editing an article, or image ?).
Correct. In the case of (multi-)select lists and check boxes etc, it uses the name not title to match. So if you defined a bunch of Options like this:
orange => Orange
sky-blue-pink => Sky-Blue Pink
mauve => Mauve
red => Red
greenish => Green(ish)
then setting ‘default’ to greenish, sky-blue-pink would preselect those two options on page load.
if the
Helpfield is left blank (no help provided for that CF), does thepophelplink appear next to the CF? Currently it does, that sounds a little odd and confusing to me.
Good call. I did spot that but forgot to fix it. There’s a bug insofar as if you don’t specify a value, it renders the raw help string name, which makes the help field think it’s populated. I’ll see if I can fix that. Thanks for the nudge.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: [RFC] Custom Fields: expirable?
Thanks for confirming and explaining my observations.
BTW, right now it is impossible to delete a CF from the multi-edit widget: select the CF, from the widget select “delete”. Result: all CF are deleted… reload the panel (or wander around to another panel and come back to the CF panel): all fields, incl. the deleted one are there.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: [RFC] Custom Fields: expirable?
Urk. I’ll fix the deletion code. It definitely used to work cos I was deleting fields a week or so ago.
Thanks for spotting it.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: [RFC] Custom Fields: expirable?
Bloke wrote #338792:
Urk. I’ll fix the deletion code. It definitely used to work cos I was deleting fields a week or so ago.
When / while you are looking at that, check the other 2 items – change content / render type. those are doing nothing atm, as far as I can see.
Thanks.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline