Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2009-08-28 17:27:02

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

Re: How can I list articles related by keyword?

Manually adding collate="0" to the tag didn’t change the output. :(

The tag-trace doesn’t seem very informative:

<txp:smd_each type="field" include="keywords" collate="0">
</txp:smd_each>

On the other hand, smd_each iterates keywords through the article_custom list with pomp, triumph, and reveling. I’m pretty happy about that part!

Here’s the tag-trace from the working instance for contrast:

<txp:smd_each type="field" include="keywords">
	<txp:article_custom section="other-section" keywords="design,inspiration,textpattern,visual storytelling,cms integration,content management" break="li">
		[SQL (0.000704050064087): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section IN ('other-section') and (FIND_IN_SET('design',Keywords) or FIND_IN_SET('inspiration',Keywords) or FIND_IN_SET('textpattern',Keywords) or FIND_IN_SET('visual storytelling',Keywords) or FIND_IN_SET('cms integration',Keywords) or FIND_IN_SET('content management',Keywords)) order by Posted desc limit 0, 10]
		[article 129]
		<txp:permlink/>
		<txp:title/>
		[article 128]
		<txp:permlink/>
		<txp:title/>
	</txp:article_custom>
</txp:smd_each>

Offline

#14 2009-08-28 18:27:39

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

Re: How can I list articles related by keyword?

johnstephens wrote:

Even this code outputs the keywords array as a single string, contained in a single li pair

Oh, duh, sorry. Dunno why I didn’t pick up on it earlier. It’s an interesting “feature” of the plugin.

Essentially the plugin was written to handle lists of strings e.g. include="my, list, of, items". When dealing with fields the landscape alters slightly because you could in theory specify this: type="field" include="custom1, custom2, custom6, excerpt". Those things might hold one item each, but they might themselves hold lists. In that case you need to tell the plugin that they might hold lists by using subset="1" or subset="2". So what you were seeing was the plugin treating your sublist (keywords) as a single entity.

Sorry for the misdirection and confusion earlier. Been a long day. Look up the subset option in the plugin docs and see if it helps; it probably won’t ‘cos the example I chose was crap :-)


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

#15 2009-08-28 18:56:13

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: How can I list articles related by keyword?

johnstephens wrote:

<txp:smd_each type="field" include="keywords">
	<txp:article_custom section="other-section" keywords="design,inspiration,textpattern,visual storytelling,cms integration,content management" break="li">
		[SQL (0.000704050064087): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section IN ('other-section') and (FIND_IN_SET('design',Keywords) or FIND_IN_SET('inspiration',Keywords) or FIND_IN_SET('textpattern',Keywords) or FIND_IN_SET('visual storytelling',Keywords) or FIND_IN_SET('cms integration',Keywords) or FIND_IN_SET('content management',Keywords)) order by Posted desc limit 0, 10]
		[article 129]
		<txp:permlink/>
		<txp:title/>
		[article 128]
		<txp:permlink/>
		<txp:title/>
	</txp:article_custom>
</txp:smd_each>

johnstephens, I may be wrong, but didn’t you want to “feed” just one keyword at time? As for that tag trace, you are feeding all keywords at once, which then, it helps to understand the “issue” (not an issue, as Bloke demonstrated) you were having as {var_value}. was always returning a list of comma-separated keywords (on both places it was being used: (<li>{var_value}</li>, and <txp:article_custom keywords"="{var_value}" />).

But if you are getting the right output then: is it just a coincidence? or am I missing something?

Last edited by maniqui (2009-08-28 18:56:32)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#16 2009-08-28 19:15:55

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

Re: How can I list articles related by keyword?

Magnificent, thanks! subset="2" was the answer. It is so perfect I could weep!

Offline

#17 2009-08-28 21:04:19

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: How can I list articles related by keyword?

Looks like you accomplished what you needed to, but I think the tru_tags plugin (http://www.rainskit.com/reference/537/tru_tags-releases) is very helpful for dealing with keywords.

Offline

#18 2009-09-01 16:37:32

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

Re: How can I list articles related by keyword?

Hi, Nora— I’m a appreciator of your Textpattern instructional videos, and I saw your tru_tags video demo several months ago. I do use tru_tags on this site, but it doesn’t allow for some of the things I’m trying to do with this site’s taxonomy. I’ll post a demo once I get the content more fleshed out.

As far as I can tell, tru_tags provides no clear way to do what I described here: display a list of related articles for each keyword.

What I like about tru_tags is the keyword maintenance features it provides on the admin-side. This is also a strong-suit of smd_tags (a very strong suit), but smd_tags doesn’t currently interact with the txp:keywords field.

Offline

Board footer

Powered by FluxBB