Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2008-10-17 15:41:26

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

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

mrdale wrote:

Hey, while you’re at it… ;) how about a global category for all content types.

Welcome to xPattern :-)

EDIT: Actually, that might be doable. Hmmm…. *stef dons his deviant coder's hat*

Last edited by Bloke (2008-10-17 15:44:18)


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

#26 2008-10-17 16:23:47

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

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

BTW: I realize that every time you release something brilliant, I immediately say “Oh hay. Can haz X and Y?”

Offline

#27 2009-01-11 19:12:11

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

Howdy!

I’m testing the smd_related_tags tag, and I keep getting the following errors:

Notice: Undefined variable: uLastMod  on line 906
Notice: Undefined variable: uExpires  on line 929

Here’s the tag generating the error:

<txp:smd_related_tags type="article" section='<txp:section />' label="Possibly related" labeltag="h3" wraptag="ul" break="li" />

I get the same errors if I add match="keywords" attribute.

Did I do something wrong in the setup phase? I’m running TXP 4.0.7 with MySQL 5.0.41.

Offline

#28 2009-01-11 19:52:04

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

I think I found the solution— thanks, Stef!

I edited the client-side plugin, replacing uPosted with uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod all the way, and the error messages went away. Hopefully this is a healthy, wholesome solution that won’t destroy me down the road. ;)

Offline

#29 2009-01-12 02:43:31

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

from Admin help:

Default section for tags : Any links from the client-side tags will be sent to this section for display. Can be overridden on a tag-by-tag basis with the section_link attribute.

This sounds like the smd_tags analogue to <txp:tru_tags_handler />, but I can’t figure out how to configure out how to configure a landing page for tag links.

With tru_tags, my setup worked like this:

<txp:if_section name="tags">
	<txp:tru_tags_handler />
	<txp:else />
	// content //
</txp:if_section>

What’s the proper way to setup smd_tags’s default section? I’ve tried something akin to this:

<txp:if_section name="tags">
	<txp:smd_tag_???>
			<h3><txp:title /></h3>
			<txp:rss_auto_excerpt paragraphs="1" />
	</txp:smd_tag_???>
	<txp:else />
	// content //
</txp:if_section>

smd_if_tag_list

Conditional tag that returns true if the current scope is a global tag list. Useful for detecting if a tag has been clicked and redirected to a landing page so you can take some action on that page.

From this snippet, I thought smd_if_tag_list was the tag to use here, but I haven’t found the correct way to get it working.

I would be grateful for any guidance offered on this! Thanks!

Last edited by johnstephens (2009-01-12 02:47:39)

Offline

#30 2009-01-15 00:22:04

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

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

johnstephens wrote:

What’s the proper way to setup smd_tags’s default section?

Hi John, sorry for the delay in getting back to you. The main difference between smd_tags and tru_tags in this regard is that you do not need a handler in smd_tags. It is automatic.

First of all, go to the plugin prefs and make sure you set up the name of a section to be your landing page. You can leave URL name parameter and URL type parameter alone for now.

Let’s say you chose smd_tags as your default page. Create a section smd_tags and assign it a Page. It could be the same Page as you already use; in which case you need to use the conditional <txp:smd_if_tag_list>... your tag shenanigans...</txp:smd_if tag_list> to separate it from your regular content. If this is a dedicated page template in a dedicated section you don’t need to use the conditional tag, though it’s probably good practice.

OK, so inside your conditional you might put something like this:

<h2>Tags list</h2>
<txp:smd_tag_list>
  <txp:smd_tag_name title="1" link="1" />
  <txp:smd_tag_count />
  <txp:smd_related_tags wraptag="ul" break="li">
    <txp:smd_if_tag type="file">
       <txp:file_download_link><txp:file_download_description /></txp:file_download_link>
    </txp:smd_if_tag>
  </txp:smd_related_tags>
</txp:smd_tag_list>

Phew! That uses <txp:smd_tag_list /> as a container and outputs all tags of the given type. It shows the tag name and its article count, then it goes away and looks for all related tags that share the current (article) tag name. It assembles a complete list of those behind its back and the conditional <txp:smd_if_tag type="file"> takes a look at each one. If it is a tag associated with a file, it displays the download description of that file. If it’s a tag of any other type (link, image, article) it ignores it.

That’s all well and good but how do you give it a starting point? That’s where the URL comes in:

site.com/smd_tags/article

will show all article tags and — if they share any tags with files — will show those too as a list.

site.com/smd_tags/file

will show all file tags and — if they share any tags with other files — will show those too as a list. And so on.

site.com/smd_tags/article/tiger

will show the article tag ‘tiger’ and — if any files also have the tag “tiger” — will show those as a list.

In this way, you can construct URLs that allow you to browse tags in a way that makes sense to your visitors. For example, if you have a traditional article and have tagged it with tiger big stick poke roar chomp ouch hospital you could list all the tags under your article in your article form:

<txp:permlink><txp:title /></txp:permlink>
Filed in: <txp:category1 link="1" title="1" />
Tags: <txp:smd_tag_list><txp:smd_tag_name link="1" title="1" /></txp:smd_tag_list>

That makes a clickable link from each tag to your default tag section. So, in theory (you’ll see why in a sec) if you click on “roar” it will take you to the URL site.com/smd_tags/article/roar and on that Page you can do whatever you want: list other articles with the same tag, list other files that share the tag (like the example above), list other links that have the same category as the given tag. The sky’s the limit.

Well, it would be, except I think the URL scheme is broken :-( At least it’s broken in my dev copy. It might be because I killed it with something I did as I’m developing v0.2 or it could be that it’s also broken in v0.11.

In v0.11, the link="1" creates ‘messy’ URLs that use those other two attributes in the smd_tags prefs. It then makes links like:

site.com/smd_tags?smd_tagtype=article&smd_tag=roar

Behind the scenes the plugin is supposed to figure out what that means and present the correct list as if you’d done it with a clean URL. But I don’t know if it does. If not you can still make it work by manually constructing clean URLs in your anchors, but it’s a hassle you could do without. Taking the current permlink mode into account is slated for v0.2 (now I understand it all a bit more!)

YMMV: it might work as indicated above or may not. I know of a few other people using v0.11 and they’ve not complained so perhaps it is working; or perhaps they’re not using it in this way.

If it doesn’t work I will do my level best to get v0.2 out asap. I’m snowed under with a client site right now but should be clear in a few weeks. I know I’ve been promising this one for ages and I’m sorry it’s not quite all there but I’ll try and get this darn plugin singing like it should as soon as I can.

Does that give you any ideas or have I completely flummoxed you now? :-)

Last edited by Bloke (2009-01-15 00:24: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

Offline

#31 2009-01-15 03:10:51

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

Thanks so much for your detailed reply! I know what it’s like to be snowed under by client work, and I don’t blame you for minding your priorities.

Everything up to this point is working fine:

site.com/smd_tags/article will show all article tags and — if they share any tags with files — will show those too as a list.

Check!

site.com/smd_tags/file will show all file tags and — if they share any tags with other files — will show those too as a list. And so on.

Don’t have any files, so I get a warning: Notice: Uninitialized string offset: 0 on line 1399. This, I don’t mind so much.

site.com/smd_tags/article/tiger will show the article tag ‘tiger’ and — if any files also have the tag “tiger” — will show those as a list.

This url (using a valid article tag in place of tiger) returns error 404. If I omit the /article url segment, I get the tag list again, displaying perfectly.

In this way, you can construct URLs that allow you to browse tags in a way that makes sense to your visitors. For example, if you have a traditional article and have tagged it with tiger big stick poke roar chomp ouch hospital you could list all the tags under your article in your article form:

<txp:permlink><txp:title /></txp:permlink> Filed in: <txp:category1 link="1" title="1" /> Tags: <txp:smd_tag_list><txp:smd_tag_name link="1" title="1" /></txp:smd_tag_list>

That makes a clickable link from each tag to your default tag section.

Check! This works flawlessly for me.

So, in theory (you’ll see why in a sec) if you click on “roar” it will take you to the URL site.com/smd_tags/article/roar and on that Page you can do whatever you want: list other articles with the same tag, list other files that share the tag (like the example above), list other links that have the same category as the given tag. The sky’s the limit.

Well, it would be, except I think the URL scheme is broken :-( At least it’s broken in my dev copy. It might be because I killed it with something I did as I’m developing v0.2 or it could be that it’s also broken in v0.11.

I think that’s the case in the version I’m using. Clicking on any links generated by the link="1" attribute leads to the tags section, but no content there.

Behind the scenes the plugin is supposed to figure out what that means and present the correct list as if you’d done it with a clean URL. But I don’t know if it does. If not you can still make it work by manually constructing clean URLs in your anchors, but it’s a hassle you could do without. Taking the current permlink mode into account is slated for v0.2 (now I understand it all a bit more!)

How would I construct a clean url that would show me a list of articles matching a certain tag? I find I can usually construct something once and drop it into a form for reuse.

If I turn off tag links, I can still display article tags on the article, and make use of smd_related_tags to show related articles. I don’t have “browse by tag” functionality yet, but I don’t mind holding off on that until the next version is out, or sooner if someone can identify what I’m doing wrong.

YMMV: it might work as indicated above or may not. I know of a few other people using v0.11 and they’ve not complained so perhaps it is working; or perhaps they’re not using it in this way.

I’d love to hear from others using the plugin to find out if and how they’ve implemented browsing by tag.

If it doesn’t work I will do my level best to get v0.2 out asap. I’m snowed under with a client site right now but should be clear in a few weeks. I know I’ve been promising this one for ages and I’m sorry it’s not quite all there but I’ll try and get this darn plugin singing like it should as soon as I can.

Does that give you any ideas or have I completely flummoxed you now? :-)

Immensely helpful, thank you! I’m very grateful for your help, and I think I have a marginally better grasp of how it will work!

Offline

#32 2009-01-15 05:51:03

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

The only thing I miss from tru_tags is that it pulled double duty for meta keywords on individual articles. Is there a way to automate duplicating your tags as keywords? The easiest option I’ve found is to use the textarea input option and copy and paste. I’m probably the only one who would ask for this feature, so take it with a grain of pepper.

Thank you again for the awesome plugin!

Offline

#33 2009-01-15 06:40:15

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

Sorry to trouble you again, I didn’t imagine this would be a problem:

How do I set smd_related_tags to only output articles with “live” status? Textpattern’s native tags naturally exclude sticky content unless called to do so. I’m getting links to sticky articles included in the mix, but the links go to no content: Here’s an example: Under “Possibly Related,” there’s a link to “A blog about peacebuilding, social marketing & visual storytelling”, which is the sticky article on the blog’s landing page.

My default page uses this to distinguish if you’re on a section landing page or an individual article:

<txp:if_article_list>
	<txp:article limit="1" status="sticky" />
	<txp:else />
	<txp:article />
</txp:if_article_list>

As a result, there’s no content at http://designop.us/wrote/updated-every-year-whether-it-needs-it-or-not. That way, the section-page content lives in one place, and I like that.

My related articles tag looks like this:

<txp:smd_related_tags type="article" section='<txp:section />' label="Possibly related" labeltag="h3" wraptag="ul" break="li" />

Since smd_related_tags doesn’t accept a status="live" attribute, I’m not sure what to do. The default behavior of most native tags seems to be ignoring sticky content unless there is a specific declaration.

EDIT: I changed my default page as a stop-gap until I figure out how to exclude sticky articles from related content— now my default page includes an extra line: <txp:article status="live" /> ↩ <txp:article status="sticky" />. This creates duplicate content, but I’m not sure what else to do.

Last edited by johnstephens (2009-01-16 21:03:15)

Offline

#34 2009-01-19 00:41:49

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

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

johnstephens wrote:

Don’t have any files, so I get a warning: Notice: Uninitialized string offset: 0 on line 1399.

Thanks for the report. I think I’ve fixed that in the next release but I’ll verify it.

This url (using a valid article tag in place of tiger) returns error 404. If I omit the /article url segment, I get the tag list again, displaying perfectly.

Arse. OK, I’ll try and find out why that’s misbehaving. Works for me. *ponder*

Clicking on any links generated by the link="1" attribute leads to the tags section, but no content there.

As I suspected: the URL scheme is brain dead. Apologies, I’ll get that in order.

How would I construct a clean url that would show me a list of articles matching a certain tag?

In theory it’s just <a href="site.com/your_nominated_tag_section/tag_type/tag_name">Filter time!</a> but for some reason it doesn’t seem to work on your system, despite working on mine. Will do some digging.

I’d love to hear from others using the plugin to find out if and how they’ve implemented browsing by tag.

Me for one! I’ll try and distill some examples from my working test site when I get a chance and post them here for you to try. It may well be because I’m running the latest dev snapshot though and I’ve probably fixed the obvious stuff.

Is there a way to automate duplicating your tags as keywords?

Not keywords as in “they go in the keywords box in the Write tab” but you can probably cajole smd_tag_list into something like this (untested):

<meta name="keywords" content="<txp:smd_tag_list wraptag="" break=","><txp:smd_tag_name /></txp:smd_tag_list>" />

Or some equivalent functionality to show lists of tags that you can pretend are keywords!

I’m actually rethinking the client tags a bit based on stuff I learned while doing smd_calendar to make the defaults a bit more logical and allowing you to do more flexible stuff with them. That should make the tag cloud much easier to write as it’s just an extension of smd_tag_list with some custom weighting that you can control.

Also on the cards is a converter to copy your article tru_tags or rss_unlimited_catgeories into smd_tags so you can experiment with them all and see which you prefer.

To actually copy the smd_tags to the keywords field, erm, I dunno. Hadn’t really considered it. If there’s a business case for it, I’ll find a way!

How do I set smd_related_tags to only output articles with “live” status?

Yikes, that’s a collosal oversight on my part. Sorry about that. I’ll add a status filter to that (and other) tags. Thanks for letting me know about this one.

For now you can hack the plugin to do what you want. In smd_tags_client, scroll down to just over halfway (probably around lines 380-390) and look for:

case "article":
  $rs = getRows("SELECT " ........

A couple rows further on you’ll see a line starting:

WHERE tu.type='article'" . $excludeClause .....

Change it to:

WHERE tu.type='article' AND Status=4". $excludeClause .....

That should keep those article in check until I can fix it!

Many thanks for testing this and putting up with my crappy code. It’s embarrassing that it’s so full of holes, but if it wasn’t for good people like you willing to put it through its paces I’d never find half the problems, so a big big thank you. When I get clear of this client site (hopefully in a few weeks) I’ll turn my full attention to this plugin.


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

#35 2009-01-19 20:12:03

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

Thank you again for your detailed support!

Bloke wrote:

In theory it’s just <a href="site.com/your_nominated_tag_section/tag_type/tag_name">Filter time!</a> but for some reason it doesn’t seem to work on your system, despite working on mine. Will do some digging.

I wanted to report back to you on this, since I saw something that might be interesting. I set up my 404 page to parse the txp:page_url request_uri into a search box, using rah_replace to knock out common delimiters such as -, +, and %20— the idea was that a mistyped url string might have words in it that would be useful in a search (with smd_fuzzy_find enabled).

With my tags section named “tags”, my url name parameter called “keyword”, and my type parameter called “select”, I entered the following url, according the the clean url pattern above: http://designop.us/tags/article/textpattern

But the search box parsed in the request_uri as this: tags?keyword=textpattern amp;#38;select=article

I take that to mean the plugin is obviously doing something!

Not keywords as in “they go in the keywords box in the Write tab” but you can probably cajole smd_tag_list into something like this (untested):

<meta name="keywords" content="<txp:smd_tag_list wraptag="" break=","><txp:smd_tag_name /></txp:smd_tag_list>" />

Or some equivalent functionality to show lists of tags that you can pretend are keywords!

Cool, this is what I did, kind of. Right now I’m using rah_metas, and if there’s nothing in the keyword field for an article it appoints default keywords. Right now I have it setup like this for section landing pages:

<txp:rah_metas
	description='<txp:article limit="1" status="sticky"><txp:rss_auto_excerpt striptags="1" excerpt="subtitle" showlinkwithexcerpt="0" /></txp:article>'
	keywords='<txp:article limit="1" status="sticky"><txp:smd_tag_list wraptag="" break=", " indent=""><txp:smd_tag_name title="1" /></txp:smd_tag_list></txp:article>'
/>

Also on the cards is a converter to copy your article tru_tags or rss_unlimited_catgeories into smd_tags so you can experiment with them all and see which you prefer.

That would be very cool— Design Opus is my only site running on smd_tags right now, and one of my client sites is running on tru_tags with a immense amount of data. Being able to import tru_tags/keyword field data would be essential if we wanted to begin using this plugin instead.

Going the other way— sending smd_tags to the keywords field —would be awesome too. If there was a one-click way to dump each articles tags into keywords (all at once from the smd_tags preference pane), that would make them more interoperable. I don’t know if there’s a business case for it, though.

How do I set smd_related_tags to only output articles with “live” status?

Yikes, that’s a collosal oversight on my part. Sorry about that. I’ll add a status filter to that (and other) tags. Thanks for letting me know about this one.

For now you can hack the plugin to do what you want. […] That should keep those article in check until I can fix it!

Awesome— implemented and gorgeous! Thank you!

Many thanks for testing this and putting up with my crappy code. It’s embarrassing that it’s so full of holes, but if it wasn’t for good people like you willing to put it through its paces I’d never find half the problems, so a big big thank you. When I get clear of this client site (hopefully in a few weeks) I’ll turn my full attention to this plugin.

I’m just happy to list related articles on a more granular basis than category!

Offline

#36 2009-01-26 14:58:45

woof
Member
Registered: 2004-08-01
Posts: 128

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

Nice plugin Stef. The tag nesting is great. I’m giving it a go and have a question re: use of the “parent” attribute:

I have my tags set up along these lines:

years
-2007
-2008
-2009
locations
-new york
-london
-paris
-munich

etc, etc

I have an article tagged with “london” and “paris” and am using the following in my article form:

<txp:smd_tag_list type="article" parent="locations"> <txp:smd_tag_name link="1" title="1" /> </txp:smd_tag_list>

I would expect this to output “London, Paris” but no, its blank. However if I go back and ensure it is also tagged with the parent “locations” …it works perfick.

Is this correct behaviour? — IE is it necessary to tag an article with a parent tag in order to display child tags? — or am I doing something wrong?

Last edited by woof (2009-01-26 14:59:31)

Offline

Board footer

Powered by FluxBB