Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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.
Offline
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
Re: Article list by author is not treated like article list by category
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
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