Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-03-15 13:24:03

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Pre-fill new article body with starter content?

Has there ever been a plugin that can be configured to pre fill new article’s body field with some starter text?

There are certain elements, while not super complicated to write, I nevertheless can’t remember how to write correctly (macro tags, endnotes lists, etc.) so I have to go look somewhere else — a previous article, the Textile demo site, etc — copy/paste, blah-blah. If there was a way to have generic parts of things like pre filled at the touch of a button, that would add up to some serious hell yeah!

For example, just having this waiting in the body field when creating a new article would be a big help:

<smd:macro name="figure" id="x" />

<hr class="fnotes">

<txp:hide> 
The following Textile syntax creates the endnotes list. 
The note IDs come from citation labels like this.[#ref]
The back-link character can not be an arrow, caret, or other useful glyph, but a dagger will work.
Basic reference and annotation format:
First Last, "Title of piece," __Name or Title of Source__, Specifics, (Publisher, Place), Date, URL. %(annotation)[Author comments here]%
</txp:hide>

notelist(endnotes):†.

note#ref. First Last, "["Title of piece":url]," __Name or Title of Source__, Specifics, (Publisher, Place), Date, URL. %(annotation)[Author comments here]%

I would add an typical table grid too with all classes pre-filled, and any other special elements with hard-to-remember classes. Huge time savings. Easy to delete it out over typing it in or copy/pasting something in that then needs old content edited out.

I’m not even sure that’s a correct example of a smd_macro tag off the top of my head, which is exactly one of my issues to solve here.

I guess I could create a dummy article in perpetual draft to copy/paste from, but that seems wanky at best.

Just curious.

Such a plugin could be used to pre-fill categories, custom fields, and whatever else somebody wanted as a default place to begin, if not blank.

Offline

#2 2018-03-15 13:56:45

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,456
Website GitHub

Re: Pre-fill new article body with starter content?

Never heard of such a plugin, but it sounds like a potentially useful addition, especially if you don’t want to keep draft docs around.

If I was writing it, I’d probably allow you to define your “snippets” in Forms. Maybe the Form naming convention could indicate to which fields they are associated or something. A plugin could read those and either offer a dropdown that allows you to grab the content of a Form and splat it in the nearby field. Or it could auto-insert stuff when creating a new article. Dunno.

Incidentally, there’s always adi_notes. That allows you to put stickies on the page.

For smaller hints, add language strings to your database (txp_lang table) to benefit from a largely undocumented yet hugely useful feature: built-in inline help beneath the label of any field in any chosen UI language(s). Just find the name of the field in the HTML form (you can use your brower’s inspector if you need to find this out) and prefix it with instructions_. e.g. to add inline help to the body field of the Write panel (event=article) create a new row in your txp_lang table thus:

lang: en
name: instructions_body
event: article
owner: destry
data: Main content goes here. Use <smd::macro name="figure" id="x" /> for figures.

Boom.

EDIT: drat, putting HTML text in the instructions field is gobbled up by the sanitizer. Alright, it’s useful for non-html inline help ;-)

Last edited by Bloke (2018-03-15 14:10:43)


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

Online

#3 2018-03-15 14:02:33

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,734
Website

Re: Pre-fill new article body with starter content?

Or create a dummy article in draft status with your starter setup and duplicate that when you start writing an article ;-)

EDIT: I should read more carefully rolls eyes. You wrote that already, although given the duplicate article function, I think that’s legit

Another way is to use a program like textexpander / keyboard maestro & co to insert your draft text on a particular key combo. That’s not a textpattern solution but still workable.


TXP Builders – finely-crafted code, design and txp

Offline

#4 2018-03-16 08:59:11

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Pre-fill new article body with starter content?

Bloke wrote #309951:

For smaller hints, add language strings to your database (txp_lang table) to benefit from a largely undocumented yet hugely useful feature: built-in inline help beneath the label of any field in any chosen UI language(s).

EDIT: drat, putting HTML text in the instructions field is gobbled up by the sanitizer. Alright, it’s useful for non-html inline help ;-)

Good to know anyway. Thanks!

Offline

#5 2018-03-16 09:04:28

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Pre-fill new article body with starter content?

jakob wrote #309952:

…create a dummy article in draft status

[or] use a program like textexpander / keyboard maestro & co to insert your draft text on a particular key combo. That’s not a textpattern solution but still workable.

Problem with the draft article approach is it moves around too much as articles accumulate. Just having to find and open the damn thing is annoying. But the “Duplicate” article feature would offset that a bit. At least you don’t have to copy/paste action too.

As for third-party stuff and keyboard combos… I don’t want the former and can’t ever remember the latter. I’m really looking for something instant-added, then just edit in place.

Offline

#6 2018-03-16 15:29:00

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,734
Website

Re: Pre-fill new article body with starter content?

Destry wrote #309985:

Problem with the draft article approach is it moves around too much as articles accumulate. Just having to find and open the damn thing is annoying. But the “Duplicate” article feature would offset that a bit. At least you don’t have to copy/paste action too.

(Yet) Another idea: if it’s possible to write out the article clone button as a link that clones your preset draft article and then put that as a “Create new draft” button on an smd_tabber dashboard panel. It depends if that works. Otherwise you could certainly make a dashboard link to the draft article so you don’t need to search for it.

@devs: I don’t fully understand how the ‘clone’ button works. It seems to be a javascript trigger that passes copy:1 to the form/submit button. Can that be written in another form as a full link that could be placed elsewhere (i.e. not from the write pane with the article loaded)?

I’m thinking of something like ?event=article&step=edit&ID=123&copy=1 or similar…


TXP Builders – finely-crafted code, design and txp

Offline

#7 2018-03-16 15:49:06

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

Re: Pre-fill new article body with starter content?

jakob wrote #310015:

@devs: I don’t fully understand how the ‘clone’ button works. It seems to be a javascript trigger that passes copy:1 to the form/submit button. Can that be written in another form as a full link that could be placed elsewhere (i.e. not from the write pane with the article loaded)?

I’m thinking of something like ?event=article&step=edit&ID=123&copy=1 or similar…

Not in the present form (even for usual article saves) since we fetch the data from $_POST.

Edit: though shouldn’t be too difficult to change in such a way that article 123 fields are only copied, but not saved. But then it’s almost the same that ?event=article&step=edit&ID=123 plus duplicate UX wise.

Last edited by etc (2018-03-16 15:58:17)

Offline

#8 2018-03-16 16:20:09

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,734
Website

Re: Pre-fill new article body with starter content?

etc wrote #310018:

Not in the present form (even for usual article saves) since we fetch the data from $_POST.

Edit: though shouldn’t be too difficult to change in such a way that article 123 fields are only copied, but not saved. But then it’s almost the same that ?event=article&step=edit&ID=123 plus duplicate UX wise.

If it’s easy to implement, please! It would be useful to make ready-made article templates for clients to start from.


TXP Builders – finely-crafted code, design and txp

Offline

#9 2018-03-16 16:34:44

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

Re: Pre-fill new article body with starter content?

jakob wrote #310019:

If it’s easy to implement, please! It would be useful to make ready-made article templates for clients to start from.

If you want to test (have no much time now, sorry), add the following right before extract($rs); on line 690 of txp_article.php:

    if (gps('copy') && !ps('copy')) $rs['ID'] = $rs['url_title'] = '';

Then index.php?event=article&ID=123&copy=1 should result in a unsaved clone of 123. Note that url_title will not be changed atm, so you’ll get a duplicate title warning on save.

Edit: this is done now.

Last edited by etc (2018-03-16 23:18:22)

Offline

#10 2018-03-16 22:07:47

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Pre-fill new article body with starter content?

I’ve got something (adi_populate) that might help. I wrote it while go for a client. On an smd_tabber tab you do something like:

<txp:adi_populate button_text="Test populate" button_class="publish" Title="my title" custom_1="Custom One" Section="about" category1="Hope for the Future" keywords="key1, key2" status="pending" />

Offline

Board footer

Powered by FluxBB