Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-06-27 13:21:29

moggie
Member
Registered: 2008-06-27
Posts: 11

empty related_articles

Hi,

Firstly would like to thank everyone who puts their hard work and time into the development of textpattern, I installed it yesterday and so far have quite enjoyed learning how it works and setting it up.

I have come across a slight stumbling block though. I am trying to create a little related_articles section in a menu column that will display related articles. Unfortunately, some of my articles have no relations and therefore I am left with an empty space.

The following tag is being used to display the related articles:

<txp:related_articles break=“li” label=“Related Articles” labeltag=“h4” limit=“5” match=“Category1” sort=“rand()” wraptag=“ul” />

This works great, but when there are no related articles, I would like to be able to say that no related articles have been found, or just do something different, instead of leaving an empty space. I searched the docs and forum, and found a plugin that seems to be able to detect when something is empty, but I was wondering if textpattern had some internal method of handling this.

Thank you in advance for your time and consideration.

Regards,
Moggie.

Offline

#2 2008-06-27 13:27:14

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

Re: empty related_articles

Welcome to TextPattern!

You’ll perhaps be wanting chh_if_data then. Works well with TXP’s built-in <txp:else /> tag.

Last edited by Bloke (2008-06-27 13:28:49)


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 2008-06-27 13:29:51

moggie
Member
Registered: 2008-06-27
Posts: 11

Re: empty related_articles

Thanks!

Yeah perhaps so, that is a plug-in isn’t it? From what I have gathered so far textpattern doesn’t seem to have an internal mechanism for doing this sort of thing?

Offline

#4 2008-06-27 13:32:46

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

Re: empty related_articles

moggie wrote:

that is a plug-in isn’t it?

Yes.

From what I have gathered so far textpattern doesn’t seem to have an internal mechanism for doing this sort of thing?

I don’t believe so, but if anyone will be able to tell you, it’ll be Els. She’s the guru of devious tag usage :-)


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

#5 2008-06-27 13:47:59

moggie
Member
Registered: 2008-06-27
Posts: 11

Re: empty related_articles

Bloke wrote:

I don’t believe so, but if anyone will be able to tell you, it’ll be Els. She’s the guru of devious tag usage :-)

Cool. Will have to wait and see – hopefully she will be kind enough to point me in the right direction, thanks for your help :)

Offline

#6 2008-06-27 14:03:51

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: empty related_articles

Hmm… thank you Stef, I’m honoured ;)

But in this case chh_if_data really is the simplest solution, so I won’t be pointing in any other direction ;)
You could do it I think with article_custom instead of related_articles, but to achieve the same you’d also need (1) a form, with (2) at least one conditional, and (3) asy_wondertag, and yes, that too is a plugin…

But why the reluctance to use a plugin? It can make life so much easier… ;)

Anyway, when 4.0.7 comes you’ll be able to do it without a plugin :)

Last edited by els (2008-06-27 14:05:18)

Offline

#7 2008-06-27 14:10:05

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: empty related_articles

Won’t <txp:if_article_category> do it? With some of your deviousness, of course, Els!


BB6 Band My band
Gud One My blog

Offline

#8 2008-06-27 14:25:36

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: empty related_articles

zero wrote:

Won’t <txp:if_article_category> do it? With some of your deviousness, of course, Els!

Sure, but you’d need asy_wondertag to match it with category1. So since chh_if_data requires the least amount of code, I’d prefer to use the latter :)

Sorry for the lack of deviousness here, only laziness this time…

Offline

#9 2008-06-27 14:36:49

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

Re: empty related_articles

Els wrote:

(Re: <txp:if_article_category>)

Sure, but you’d need asy_wondertag to match it with category1.

Yes, otherwise that would be a very cool solution; will of course be possible natively when 4.0.7 comes along with its shiny tags-in-tags parser. Yum :-) And, I believe, <txp:related_articles /> will take a form as well, which is darn handy.

Not sure how you’d use <txp:if_variable /> in this case, but my brain’s not in the same spatial plane as Els’ so perhaps I just need to think it through.


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

#10 2008-06-27 15:18:28

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

Re: empty related_articles

Els wrote:

Anyway, when 4.0.7 comes you’ll be able to do it without a plugin :)

Hi Els!
How is that? Care to post an example? I’m jealous… you know, I used to be “king of tags combination” (thebombsite used to call me that way) here… You may be my queen!

Also, “ I can’t get the usefulness of this.

Last edited by maniqui (2008-06-27 17:33:34)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#11 2008-06-27 17:21:06

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: empty related_articles

Bloke wrote:

Not sure how you’d use <txp:if_variable /> in this case

maniqui wrote:

How is that? Care to post an example?

Damn, exposed… the rise and fall of a guru of devious tag usage within just one forum thread…

Honestly, I thought the penny had dropped, but when I tried to post a code example, I realized it must have slid into the drain immediately…
Julián, I’m with you, I don’t get it. At least not all of it. Not yet. (You see I’m not giving up. If I can’t be a guru, that queen idea is quite interesting ;) )

Offline

#12 2008-06-27 19:30:27

moggie
Member
Registered: 2008-06-27
Posts: 11

Re: empty related_articles

Els wrote:

But why the reluctance to use a plugin? It can make life so much easier… ;)

Anyway, when 4.0.7 comes you’ll be able to do it without a plugin :)

It’s not that I’m reluctant to use a plugin, it’s just I’d prefer not to add stuff to gain functionality that may already exist, so wanted to ask and make sure. It’s no problem though, I added the plugin and it works fine, thanks :)

Yeah sounds like 4.0.7 will come with a few neat features. I upgraded to 4.0.6 to get the <txp:if_search_results> functionality, which was quite handy.

Thanks again.

Offline

Board footer

Powered by FluxBB