Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-07-09 10:26:41

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

smd_write_cats: create categories on the fly from the Write tab

In response to a request from wornout this tiny plugin simply allows you to type categories directly in a new box on the Write tab (beneath the existing category selects) to have them created and assigned to your article automatically when you save it.

Nothing more, nothing less.

Download it and report the usual goodness / badness / indifferenceness here.

Revision history
————————

All available versions and changes are listed here. Each entry indexes the relevant post(s) in the thread to learn about the features.

  • 06 Jul 10 | 0.10 | Initial release
  • 11 Jul 10 | 0.20 | Added parent-child assignment ; fixed ‘article’ type selection (thanks monkeyninja / Uli) ; made tests case insensitive to prevent duplicate cats being created ; prevented ‘root’ being added to category1/2 ; added edit class to input box and made sure only people who have category privs can create them (thanks Uli)

Last edited by Bloke (2010-07-11 13:04:45)


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

#2 2010-07-09 12:41:17

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 239
Website

Re: smd_write_cats: create categories on the fly from the Write tab

I’ve been considering writing a plugin like this for a while now. Seems like I won’t have to. Thanks Stef.

Offline

#3 2010-07-09 12:51:11

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

Re: smd_write_cats: create categories on the fly from the Write tab

monkeyninja wrote:

I’ve been considering writing a plugin like this for a while now. Seems like I won’t have to. Thanks Stef.

No worries. I wrote + documented it in under an hour so if you can think of any improvements or places it’ll fall over, please holler. I think I tested it with what I consider to be a fairly full set of inputs, but I may have missed something in my haste.

I did wonder if it could be enhanced so you could specify Muppets-->Kermit, Area-->Entertainment and it’d insert Kermit and Entertainment under the given parent nodes. Not sure how many people would use it.

If there’s a clamouring for this kind of thing (or someone comes up with a better syntax) I can add it fairly easily. I’ve done this in my dev copy of smd_tags so it’d be a fairly simple copy, paste ‘n’ tweak job.


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

#4 2010-07-09 13:03:28

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,310

Re: smd_write_cats: create categories on the fly from the Write tab

, , as usual, some extra goodness Thanks, Stef!


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#5 2010-07-09 17:40:29

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 239
Website

Re: smd_write_cats: create categories on the fly from the Write tab

Bloke wrote:

I did wonder if it could be enhanced so you could specify Muppets-->Kermit, Area-->Entertainment and it’d insert Kermit and Entertainment under the given parent nodes. Not sure how many people would use it.

Perhaps a Muppets>Kermit format would be simpler and clearer? Certainly could see a use for it if people like using hierarchical category structures.

Offline

#6 2010-07-09 19:10:02

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

Re: smd_write_cats: create categories on the fly from the Write tab

monkeyninja wrote:

Perhaps a Muppets>Kermit format would be simpler and clearer?

Yeah that’d be nice. I was just trying to choose a character sequence that wouldn’t be likely to appear in someone’s Category titles though. The single greater-than seems, to me, a little risky. I could always make it a preference I suppose.

EDIT: Uli has pointed out that the categories are created even if the person doesn’t have category creation privs. Naughty me. I’ll fix that asap.

Last edited by Bloke (2010-07-09 19:10:47)


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

#7 2010-07-09 19:35:29

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 239
Website

Re: smd_write_cats: create categories on the fly from the Write tab

Bloke wrote:

Yeah that’d be nice. I was just trying to choose a character sequence that wouldn’t be likely to appear in someone’s Category titles though. The single greater-than seems, to me, a little risky. I could always make it a preference I suppose.

A preference would be great.

I’ve just given the plugin a try and come across something a little odd. It works great unless I try and add the category “Textpattern”! Tried a number of other category names and it created them, or added them, perfectly. Looking at your code I can’t see any obvious reason why I should not be able to add this category. Otherwise it’s looking good.

Offline

#8 2010-07-09 19:47:32

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

Re: smd_write_cats: create categories on the fly from the Write tab

monkeyninja wrote:

A preference would be great.

Working on it. Might have to be a hidden pref ‘cos I can’t be arsed making an entire screen for this one little thing (btw, things are afoot to help plugin authors in this regard but I’ll reveal more as TXP 5 takes shape — it’s not a 4.3.0 thing).

I’ve just given the plugin a try and come across something a little odd. It works great unless I try and add the category “Textpattern”!

Totally bizarre. I’ll check that one out, thanks for the report.

I’ve just found another subtle bug that might affect you if you make multi-word categories; it won’t correctly check if the category exists. I’m fixing that now as part of the Parent->Child thing.


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

#9 2010-07-09 19:50:05

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 239
Website

Re: smd_write_cats: create categories on the fly from the Write tab

Bloke wrote:

(btw, things are afoot to help plugin authors in this regard but I’ll reveal more as TXP 5 takes shape — it’s not a 4.3.0 thing).

You’ve got me intrigued now. Spoilers?

Offline

#10 2010-07-09 20:04:59

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,310

Re: smd_write_cats: create categories on the fly from the Write tab

monkeyninja wrote:

It works great unless I try and add the category “Textpattern”!

Seems like it has to do with the vanilla link-category “Textpattern”.

Stef, if you work on adding nested categories, separator prefs etc:
I’d prefer to write it Kermit-->Muppets, read: category Kermit goes into category Muppets.

Is it possible to have a separate pref for exchanging the order of mother and child categories fields?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#11 2010-07-09 20:36:12

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

Re: smd_write_cats: create categories on the fly from the Write tab

uli wrote:

Seems like it has to do with the vanilla link-category “Textpattern”.

/Stef slaps forehead.

I forgot to add the type to the category. What a doughnut! I swear I added that but must have deleted it by mistake as I messaed around with the code.

I’d prefer to write it Kermit-->Muppets, read: category Kermit goes into category Muppets.

Weirdo! :-p

I’ll see what I can do.

Last edited by Bloke (2010-07-09 20:36:55)


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

#12 2010-07-10 07:44:36

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 239
Website

Re: smd_write_cats: create categories on the fly from the Write tab

uli wrote:

Stef, if you work on adding nested categories, separator prefs etc:
I’d prefer to write it Kermit-->Muppets, read: category Kermit goes into category Muppets.

Is it possible to have a separate pref for exchanging the order of mother and child categories fields?

Could have it work like Kermit<Muppets for child followed by parent or Muppets>Kermit for parent followed by child. This is kind of what I had in mind with my form of notation. I suspect it complicates things a bit with Stef’s move towards a preference though.

Offline

Board footer

Powered by FluxBB