Textpattern CMS support forum
Create new content with pre-filled fields, configured by URL parameter
This may smell strongly of plugin territory and/or edge case – here for RFC nonetheless.
I’m in a position where I want to create a new article with a post-dated publication date. It’s for a journal / blog type of setup, the gist being multiple updates / edits can be made over the day, and the article goes live a set time (e.g. 23:59 local time for that day). I’d really love to be able to sanely (and safely) pre-fill some fields with dynamic information:
- date & time of publication (using
date(), epoch or similar)
- title (using
date(), percent encoded)
- section, category1 and category2
A new article is created with this syntax:
Something like this is what I have in mind:
…and so on. URL parameters follow the SQL syntax, with whatever escaping and safety nets need to be implemented.
To be clear: I’m not asking for a way to do all the shopping list above and pre-fill it, just how viable it might be to offer the parameterised approach as a basic API. I can construct a hidden page with dynamic links to profile the field content, and construct the URL accordingly.
Thanks for reading, I’d appreciate any advice on how viable this may be.
Re: Create new content with pre-filled fields, configured by URL parameter
If you don’t mind constructing a ‘catch’ page somewhere (admin side via smd_tabber, or public side if you suitably obfuscate the URL) then you could maybe use etc_query to achieve that. I’d suggest smd_query too, but etc_query is far more capable. But either of those plugins can capture URL params and construct a DB query from them.
The downside is it won’t instantly transport you to the Write panel so you can actually start editing – it’s an offline task that will create the empty article with the given params and then you can click to edit it from the Articles panel as normal.
If you’re using smd_tabber you have greater scope for a dashboard type of thing. You could set it up so you can have a bunch of form fields you fill in, which will then construct the URL params for you.
On submission of those form fields, smd/etc_query takes over, creates the empty article and, once it’s retrieved the new ID, can then forward you straight to the Write panel for immediate editing.
It largely depends on your workflow and whether this is a batch automation job or an on-demand thing. And also depends if you’re operating it and don’t mind it looking a bit Blue Peter vs making it more polished so a client can create their own pre-filled articles.
Lots of approaches but, yes, requires a plugin I expect. At least at the moment.
EDIT: When creating articles, we do have the concept of a ‘store’ – a blob of content from all form fields passed in ready to repopulate the database each time you hit Save. We might be able to open that up so it’s available on first submission rather than only after first save or make the panel respond to URL input on for new content.
Last edited by Bloke (2021-11-01 15:18:01)