Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-03-08 13:59:10

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Article list by author is not treated like article list by category

I had expected the tag <txp:author link="1" /> to act in the same way as <txp:category1 link="1" />, in that since you are then viewing in a if_article_list true context, the <txp:author /> tag would be usable.

For example, I want this:

<!-- is this an article author list? -->
    <txp:if_author>
        <h1>Articles by author: <txp:author /></h1>
        <txp:article form="article_listing" limit="5" />
    </txp:if_author>

Yet that throws up the following error:

Tag error:  <txp:author /> ->  Textpattern Notice: Article tags cannot be used outside an article context

How come that doesn’t work, when in a similar context I can legitimately have (for category listings):

<!-- is this an article category list? -->
    <txp:if_category>
        <h1>Articles in category: <txp:category /></h1>
        <txp:article form="article_listing" limit="5" />
    </txp:if_category>

Why is that?

Last edited by philwareham (2012-03-08 14:01:14)

Offline

#2 2012-03-08 14:54:25

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

Re: Article list by author is not treated like article list by category

philwareham wrote:

Why is that?

Because the <txp:author> tag is actually mis-named. It should be <txp:article_author> to give an idea of its true nature behind the scenes.

Whereas <txp:category> takes into account the category list and is also permitted to display the article category from individual article context, <txp:author> is not allowed to do likewise for author lists. It expects article context and if it doesn’t get it then by jove it’ll complain.

By rights, you are probably right that it should be retrofitted with the ability to read $thisauthor (which for reasons best left to history is actually named just $author for confusion purposes!) If I don’t hear any massive objections about why the tag can’t be retrofitted to behave the way you describe, leave it with me and I’ll fix it up for the next release.

In the meantime, try the slightly less obvious:

<txp:if_author>
     <h1>Articles by author: <txp:page_url type="author" /></h1>
     <txp:article form="article_listing" limit="5" />
 </txp:if_author>

[ Of course, that’ll probably display the author’s login name not real name *sigh*. I can’t recall offhand, but I suspect that’s the case ]

Last edited by Bloke (2012-03-08 14:55:01)


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

#3 2012-03-08 18:26:18

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: Article list by author is not treated like article list by category

Thank you Phil,
I had this query somewhere in a todolist.

Yes it is not logical. +1 for a correction.

And add an id attribute to if_individual_article. ?

Offline

#4 2012-03-26 10:25:16

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Article list by author is not treated like article list by category

Since there have been no objections to this, can we get it into the SVN soon?

Offline

#5 2012-03-26 10:59:36

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

Re: Article list by author is not treated like article list by category

philwareham wrote:

can we get it into the SVN soon?

No ;-)


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 2012-03-26 11:30:59

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Article list by author is not treated like article list by category

Brilliant!

Tested it out and all working as intended. Thanks Stef.

Offline

Board footer

Powered by FluxBB