Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-09-20 11:47:46

Alweb
Member
Registered: 2010-10-08
Posts: 25

List of articles with the same keywords (section?)

Hi forum,

I have a problem that I can’t solve. I want to have a linklist with articles that have the same keywords. I tried it with the following code.

     <h2 class="title bottom-2">Read more <span class="line"></span></h2>
      <ul class="square-list categories bottom">
<txp:article_custom keywords='<txp:keywords />' limit="99">
    <li><a href="<txp:permlink />/"><txp:title/></a></li>
</txp:article_custom>
      </ul><!-- End square-list -->
    <!-- End -->

But when the current page is a sectionarticle (Sticky), the following message is desplayed:

Tag error: <txp:keywords /> ->  Textpattern Notice: Article tags cannot be used outside an article context.  on line 2323

Can someone please help me with this?

Thanks

Offline

#2 2013-09-20 12:27:42

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: List of articles with the same keywords (section?)

Wrap it in <txp:if_individual_article></txp:if_individual_article> maybe?

Offline

#3 2013-09-20 14:02:09

Alweb
Member
Registered: 2010-10-08
Posts: 25

Re: List of articles with the same keywords (section?)

etc, thnx for your response. I already tried this, but then I don’t have a list on sticky articles…

Offline

#4 2013-09-20 14:33:54

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: List of articles with the same keywords (section?)

Ah, ok, sorry. I guess you want this list also for sticky articles on section pages? Then you can copy your default article form (to, say, related article form), append your code to it (without wrapping it in <txp:if_individual_article>), and call

<txp:article status="sticky" listform="related" />

on your page. That’s a bit redundant, but there seem to be no txp tag for article status.

Edit: listform

Last edited by etc (2013-09-20 14:48:37)

Offline

#5 2013-09-20 17:29:47

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: List of articles with the same keywords (section?)

OT: why not to replace these <txp:if_article_section/author/etc /> tags by <txp:if_article section="..." author="..." etc="..." /> with the same attributes that <txp:article_custom />?

Offline

#6 2013-09-20 19:45:37

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

Re: List of articles with the same keywords (section?)

etc wrote:

OT: why not to replace these <txp:if_article_section/author/etc /> tags by <txp:if_article section="..." author="..." etc="..." /> with the same attributes that <txp:article_custom />?

Oh, that would be extremely useful and efficient! Until this makes it into core, <txp:etc_if_article>? ;)

Offline

#7 2013-09-20 19:58:59

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: List of articles with the same keywords (section?)

Els wrote:

Until this makes it into core, <txp:etc_if_article>? ;)

But you’ve got it already:

<txp:etc_query globals="thisarticle" query="'{?section}'='blog' and '{?authorid}'='oleg' or '{?status}'='5'">
	match
<txp:else />
	no match
</txp:etc_query>

Edit: so the OP problem can be solved by putting

<txp:etc_query globals="thisarticle" query='"{?status}"="5" or "<txp:page_url type=''id'' />"'>
...related articles block...
</txp:etc_query>

in the article form.

Last edited by etc (2013-09-20 20:42:08)

Offline

#8 2013-09-20 22:32:04

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

Re: List of articles with the same keywords (section?)

etc wrote:

But you’ve got it already:

Doh! Of course :)

Offline

Board footer

Powered by FluxBB