Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-10-15 21:15:36

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

smd_tags: unlimited article, image, file and link taxonomy

After many false promises, over 6 months of rewrites / re-evaluations, and a few thousand lines of code, I’m sick of looking at it. So here is the official smd_tags for you all to break.

Download smd_tags.

It started life as smd_unlimited_categories for all Txp data types, but in the process of writing it I figured it kind of bridged the gap between the excellent rss_unlimited_categories and tru_tags. Unlimited categories was too long to keep typing, so I chose tags instead :-)

Anyway, the features:

  • Unlimited tagging for articles, images, files and links
  • Fast tagging, (almost) mouse-free system for copying, auto-naming, and optional auto-completion
  • Multi-edits and live tag search on the admin side
  • Import article tags from tru_tags and rss_unlimited_categories
  • Tag nesting
  • Optionally link tags to Txp categories so clients can only choose from a limited set of tags
  • Assign tags via a dropdown select list, a text area or a list of clickable tags
  • Set up (optional) trigger words to allow tag filtering via the URL (clean or messy: your choice)
  • List / filter tags by type and name, as lists, trees, or a tag cloud
  • Find related content by tag, or match with any Txp field
  • Tag usage counts and conditional output
  • Tag combination filters from the URL (‘+’ for AND, ‘|’ for OR, by default)
  • Global tag support

Still to do, err maybe, in no particular order:

  • Fix for foreign character autotag dumbdown
  • Tag and type paging support: next/prev/older/newer
  • Tag feed injection
  • Anything anybody thinks is reasonably missing

I am indebted to the work of those who wrote amazing stuff before and have helped guide the development. Namely wilshire, truist, merz1, net-carver and uli, plus devs past. Thank you all.

Onto the few caveats:

  • Requires minimum of Txp 4.8.0 but 4.8.1 is highly recommended. It will not run (even install properly) under Txp 4.0.x though there are no checks to warn you, it’ll just whimper a lot, run into the corner with its tail between its legs and shoot itself.
  • The autotag dumbdown for foreign (non-ASCII) characters doesn’t work; the characters will simply be ignored which is not what you want. Coding powerhouse net-carver graciously poked me in the direction of a possible (and cunning) fix but I’ve yet to try it. In the meantime if you use a lot of non-ASCII characters, consider turning off auto-tagging so Txp can make a better job of it than the plugin.
  • See the top of the source code for a list of things I know about and can’t figure out quite yet.

Anyway, I’ll stop wiffling and let you play. Once the plugin is activated, visit Extensions->smd Tags and get stuck in. There are links to the plugin help file from the admin side in case you get stuck.

I hope it’s useful. Now go play in my tagging toolshed.

Revision history
————————

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

Official:
  • 31 May 2020 | 0.8.0 | Alter plugin load order to 4 by default to circumvent 404s UPGRADERS: please alter this by hand as it won’t change on upgrade automatically ; Remove EvalElse() ; Defend against empty ‘this’ contexts in <txp:smd_related_tags> ; Append slashes in the URL handler
  • 06 Mar 2020 | 0.7.0 | Please alter plugin load order to 4 or lower For Txp 4.7.0+ ONLY ; Better support for PHP 7 (thanks, jools-r) ; Fix admin-side warnings when prefs not installed ; Kludge fix for 4.8.0 URL handling (thanks, Oleg) ; Register tags on both admin and public sides for article preview support.
  • 09 Apr 2019 | 0.6.0-beta.3 | Fix Textile warnings (thanks, jools-r).
  • 29 Jan 2019 | 0.6.0-beta.2 | Improve styling (thanks, jpdupont) ; Permit <txp:smd_if_tag> to check for search mode ; Don’t trample on core’s title attribute (thanks, helsinkifrostbites) ; Properly encode Textpack for new installs.
  • 30 Dec 2017 | 0.6.0-beta.1 | For Txp 4.7.0+
  • 09 Feb 2017 | 0.5.1-beta.1 | Update for Txp 4.6.x+ ; Removed hold-shift-for-advanced-options ; Added Textpack ; Fixed prefs page styling ; Added total tag counts and sums.
  • 05 Feb 2011 | 0.4.0 | Added live search and multi-edit functions ; improved performance ; added tag import from tru_tags and rss_unlimited_categories ; enabled delimited tag entry ; fixed rogue slashes in cat lists ; fixed URL handler and smd_tag_name to support per-section tag lists, clean URL syntax, and enabled multiple trigger words (all thanks jakob) ; PHP 5.3 compatibility fix (thanks birdhouse) ; fixed warnings in smd_related_tags ; fixed tag list when no linked cats selected and when category changed ; added ‘list’ and ‘group’ tag display options; added sort, showall and flavour to smd_tag_list for tree and tag cloud support; added lettername, lettertitle and weight items to smd_tag_info for building alphabetic tag groups and clouds ; changed table collation to utf8_general_ci and improved unicode support ; fixed bug in smd_if_tag (again!) when using non-eq tests ; added style to smd_tag_name and smd_tag_count

Beta:

  • 13 Apr 2010 | 0.3.1 | Maintenance release ; fixed smd_tag_list parent attribute (thanks woof) ; fixed smd_if_tag so it can correctly compare empty strings (thanks johnstephens); fixed admin side snafu if privs less than Managing Editor ; fixed slow response when saving tags ; fixed tag category lists if no cat(s) selected ; enhanced sublevel ; added pad_str and pad_pos to smd_tag_name ; tidied tag manager screen ; made warning messages blink
  • 23 Mar 2010 | 0.3.0 | Requires 4.2.0+ ; consolidated admin and client plugins ; added plugin lifecycle and prefs events ; fixed textarea/textarea+ jQuery ‘@’ bug and non-saves (thanks Zanza) ; fixed middot HTML entity ; added table prefix to smd_related_tags (thanks MattD)
  • 16 Apr 2009 | 0.2.0 | added Text area+”:http://forum.textpattern.com/viewtopic.php?pid=204126#p204126 ; select list size of 1 converts tag input to a single-entry dropdown (thanks thebombsite) ; fixed width of tag list in link pane ; fixed potential context array warning ; non-messy URL rewriting fixed ; began work on multi-filtering ; TXP 4.0.7+ database warnings fixed ; non-messy URL rewriting fixed ; added smd_related_tags status attribute: (thanks johnstephens) ; smd_if_tag: now correctly works outside smd_tag_list context (thanks danwoodward)
  • 16 Feb 2008 | 0.1.1 | Fixed help regarding auto-complete (thanks thebombsite) ; fixed remove table and added installation debug option (thanks jpdupont)
  • 15 Feb 2008 | 0.1.0 | Initial beta release

Last edited by Bloke (2020-05-31 10:08:59)


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

#2 2008-10-15 21:54:17

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

I’m getting a blank page when I try to install the admin plug-in (the client is OK) which suggests it’s too big. Do you have a zipped version Stef?


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2008-10-15 22:05:47

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

Re: smd_tags: unlimited article, image, file and link taxonomy

thebombsite wrote:

Do you have a zipped version Stef?

Yes, I made a zipped version but forgot to put it in the post. Haha, what was I saying about missing the obvious stuff ;-)

1st post updated, thanks for pointing that out.


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

#4 2008-10-15 22:31:15

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

Oooo! That works thanks.

It will probably take me a week to work all this out but once I get the “click”. I know you know what I mean. ;)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#5 2008-10-15 22:52:32

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

Re: smd_tags: unlimited article, image, file and link taxonomy

Yeah, I know what you mean! I kind of take the interface for granted because I’ve been staring at it for the past 6 months. Now I really need a tonne of fresh sets of eyes to find out where I’ve made crap assumptions :-)

Further to the first post, and just to clarify the position of this plugin a little, it is a hybrid of the two rss_uc and tru_tags plugins because with rss_uc the categories have to be pre-configured before they can be used whereas tru_tags — I believe — is freeformish via the keywords field.

I chose the structured approach of rss_uc and positioned the tag entry system under the categories to reflect this. My reasoning was:

  • Minimises typos
  • Gives better separation of roles: configurator-type-person and content-making type person
  • Gives site admins more control over what content authors can use as a tag (though the flipside is the content authors themselves can’t edit the tags unless they have sufficient privs — that reminds me, can someone check this out: I think I should probably test for privs before adding the ‘[Edit]’ links, thus it’ll probably just take you to a ‘restricted’ page right now)
  • Allows people with vast armies of tags the ability to subdivide them based on TXP category to make the lists more manageable. Heap thanks and praise on Markus Merz for the tag->category linkage idea. It’s not nearly as flexible as he wants it (yet) but it has huge potential for URL filtering of content once I can get my head round it
  • Tag nesting is a real bonus if used well (hint: assign a TXP category to a top-level tag and all sub-tags get pulled along with it), and is not easy without some kind of structure behind it

But after I’d done that I found a select list too restrictive. So I went back and allowed you to choose between a select list (like rss_uc), a text area or a clickable list of tags that highglight on and off (akin to the tru_tags approach). So it has the feel of neither one nor the other. The text area allows you to type in arbitrary tags but they will not be saved, which is why the jQuery auto-complete plugin is a good idea for a) saving typing and b) validating that the tags are acceptable. Depending on how strict you want the auto-complete set up, unacceptable tags can either be outright rejected if they are not connected to the current type/category or allowed to be saved if they exist somewhere for that type.

At least, that’s the theory. I’m sure this will fall over at some point and I already know of a few problems with it (esp. when deleting categories or changing category assignments in the smd_tags pane).

If there’s enough outcry I may be able to find a way of saving arbitrarily typed tags while still maintaining the structure in the back end. That sort of decision can really only be driven from people using this in anger and becoming pissed off with it!

btw, I would love to give the option to hook the entry boxes wherever you like in the interface, but the back-end DOM is such a mess of IDs and classes that frankly it’s more hassle than it’s worth (believe me, I tried!). Not to mention that the Links tab works differently to the other three…

Anyway, hopefully that’s given a bit of insight into the way the thing operates and why it does stuff the way it does.

Last edited by Bloke (2008-10-15 22:59:59)


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

#6 2008-10-15 23:06:04

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

Well the first hurdle for me was to install the auto-complete plug-in which I’ve done but then your interface asks for the js and css folders relative to “textpattern”. By that do you mean the /textpattern/ directory or the root? Maybe an example in the interface would be useful for a future release?

I’m off to bed now as I have a job to go to in the morning and they are getting scarce apparently so I shall pick this up tomorrow. :)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#7 2008-10-15 23:34:07

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

Re: smd_tags: unlimited article, image, file and link taxonomy

thebombsite wrote:

interface asks for the js and css folders relative to “textpattern”. By that do you mean the /textpattern/ directory or the root?

Ah yes, *cough* confusingly it appears to be uhh, both. The help could do with sprucing up here a bit, methinx!

For some reason I thought it was always relative to the textpattern directory (hence the hint in the admin interface) but upon reflection it seems it’s not necessarily that. Humbug. I think I changed the way it worked and forgot to update the gTxt().

For example, my structure is:

site root
  |- css
  |- files
  |- images
  |- scripts
  |- textpattern

and I can specify the two directories as the absolute paths /scripts and /css respectively, upload the two files to those directories and the plugin will pick up the auto-complete tool then. But I could also specify the two directories as ../scripts and ../css (i.e. relative to the “textpattern” directory, as if you were ‘inside’ the dir to begin with) and it will also pick them up fine. It’s your call which you prefer, but some examples would certainly be of benefit in the help file. Will add those in, thanks for the catch.

One other thing to note that I forgot to mention in the help (one of those days…) is that the plugin looks for these filenames:

jquery.autocomplete.pack.js

and

jquery.autocomplete.css

I think I intended to allow you to be able to specify the entire path + file name if you wanted but never got round to it. Perhaps next time I’ll allow you to override the file names as well if you wish, as some servers do have trouble with the .pack versions. If you get no joy with the .pack files you’ll have to edit the plugin code for now to change the file names (or cheat and rename the non-pack file with .pack in it!). Will put this on the ToDo list.

Last edited by Bloke (2008-10-15 23:46:58)


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

#8 2008-10-16 06:52:21

jpdupont
Member
Registered: 2004-10-01
Posts: 752

Re: smd_tags: unlimited article, image, file and link taxonomy

Hello Stef,

I get this when in the extension tab ( I have clicked a first time on “install tables”):

=============================
Tag tables NOT installed.
Not all table info available.

This is either a new installation or a different version
of the plugin to one you had before.

Click “Install tables” to add or update the tables
leaving all existing data untouched.
==========================

Now, if I click again on the Install table I get this errors :

==========================
Warning: Duplicate entry ‘1’ for key 1 INSERT INTO `txp_smd_tags` VALUES (1, ‘root’, ‘article’, ‘’, 1, 2, ‘root’) in /home/.navy/ampmultimedia/56tti.info/textpattern/lib/txplib_db.php on line 81
1. Duplicate entry ‘1’ for key 1

Warning: Duplicate entry ‘2’ for key 1 INSERT INTO `txp_smd_tags` VALUES (2, ‘root’, ‘link’, ‘’, 1, 2, ‘root’) in /home/…..info/textpattern/lib/txplib_db.php on line 81
2. Duplicate entry ‘2’ for key 1

Warning: Duplicate entry ‘3’ for key 1 INSERT INTO `txp_smd_tags` VALUES (3, ‘root’, ‘image’, ‘’, 1, 2, ‘root’) in /home/…….info/textpattern/lib/txplib_db.php on line 81
3. Duplicate entry ‘3’ for key 1

Warning: Duplicate entry ‘4’ for key 1 INSERT INTO `txp_smd_tags` VALUES (4, ‘root’, ‘file’, ‘’, 1, 2, ‘root’) in /home/………info/textpattern/lib/txplib_db.php on line 81
4. Duplicate entry ‘4’ for key 1
Textpattern
=============================

Offline

#9 2008-10-16 08:40:45

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

Re: smd_tags: unlimited article, image, file and link taxonomy

jpdupont

Hello, that is baffling. I did find a small bug in the remove tables procedure (I left a table behind) and that’s fixed now, but that shouldn’t affect the installation.

So you got no other error messages on screen? No SQL warnings? Did you try it with your site in debugging mode to see if it gave any errors that might help me track this down?

If you download the latest version 0.11 [ zipped ], try putting this in your URL bar:

index.php?event=smd_tags&step=smd_tags_table_remove&debug=1

Run it and see what you get out. You should see:

++ TABLE smd_tags HAS 0 COLUMNS; REQUIRES 7 ++
++ TABLE smd_tags_cat HAS 0 COLUMNS; REQUIRES 2 ++
++ TABLE smd_tags_used HAS 0 COLUMNS; REQUIRES 3 ++

Then, instead of clicking Install tables, put this in your URL bar:

index.php?event=smd_tags&step=smd_tags_table_install&debug=1

Run it and see what you get out. You should see a whole hunk of SQL commands and then:

++ TABLE smd_tags HAS 7 COLUMNS; REQUIRES 7 ++
++ TABLE smd_tags_cat HAS 2 COLUMNS; REQUIRES 2 ++
++ TABLE smd_tags_used HAS 3 COLUMNS; REQUIRES 3 ++

If it’s any different from any of that, can you post what you see please (or e-mail it to me)? Also please let me know what versions of PHP and MySQL you have, and the TXP SVN revision you have installed. And if you can log into your MySQL database (or use the rss_admin_db_manager plugin), would you please check that there are three extra tables in your Textpattern database: smd_tags, smd_tags_used and smd_tags_cat.

I can’t make it fall over here, but then I’m using old PHP4 and MySQL4. Maybe things have changed in the v5 products and I need to track these subtle differences down. Thanks for your patience.

Last edited by Bloke (2008-10-16 08:50:31)


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

#10 2008-10-16 13:30:20

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

Re: smd_tags: unlimited article, image, file and link taxonomy

Many thanks to jpdupont who graciously gave me a login to test and fix what I’d done wrong.

And I had done wrong; I’d been inconsistently using the table prefix throughout the code and hadn’t spotted it because I don’t use a prefix. Tut tut, where do they get these rookie coders from? ;-)

Anyone who has downloaded admin v0.11 should go and grab the updated copy with the fixes in it (make sure you force refresh the link in case it’s been cached). Since I only half made a fix this morning I completed it now and re-issued it under the same name. Yeah I know, if I was doing it properly and using git I wouldn’t get away with it…

Apologies to anyone with prefixes on their tables who have been scratching their heads. That should get you going. I shall now humbly slink away and pretend I’m not crap.

Last edited by Bloke (2008-10-16 13:31:20)


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

#11 2008-10-16 15:21:40

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

This is fun Stef. :)

Anyway I’m not sure if I was misunderstanding something but if I had “Enter tags using” set to “Select list” then set the “Select/textarea rows” option to “1”. I was expecting to see a “drop-down” select list as I had 5 tags defined but all I get is a single-line box with no drop-down arrow like it were a single-line textarea. Then I check the source code and see that the “select” tag is set to “multiple”. Well that’s logical as we are supposed to be able to use multiple tags so really what I need to see is ALL the available tags. I’ve found that setting the “Select/textarea rows” to “0” automatically displays the full list of available tags. I mention this as I’m thinking that if you choose to use the select list option it might be handy if it were possible to auto-set the rows to zero and make that field non-editable or am I off-centre with something here??

Last edited by thebombsite (2008-10-16 15:22:13)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#12 2008-10-16 15:58:08

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

Re: smd_tags: unlimited article, image, file and link taxonomy

thebombsite wrote:

set the “Select/textarea rows” option to “1”. I was expecting to see a “drop-down” select list

That’s a good point. Hadn’t thought of that. I can certainly detect the single row situation and make the select list a “proper” (non-multiple) drop down in that case.

To my mind it makes sense to force it to a single dropdown (hehe, less coding!); if someone’s going to the trouble of making the select list a single item, chances are you don’t want to be able to select multiple items. Right? Wrong?

setting the “Select/textarea rows” to “0” automatically displays the full list of available tags.

I didn’t know that; well found!

it might be handy if it were possible to auto-set the rows to zero and make that field non-editable

Well, that’d be fine until you have 400 tags to choose from, then your box becomes veeeery big :-)

My gut feeling is:

  • Set the Select/textarea rows to 0 shows all the tags with no scrollbar and you take the hit on how big it is
  • Set it to 1 and you get a classic, single-selection dropdown. In other words, effectively demote the plugin to ‘category3’
  • Set it to some other number and you get that many tags (rows) showing, plus a scrollbar

What do you think?


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

Board footer

Powered by FluxBB