Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2022-09-19 05:05:58

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,877
Website GitHub Twitter

latest article per author

Is there a way to post the latest article per author without having to repeat the article_custom tag like below?

<txp:article_custom author="auth1" limit="1" />
<txp:article_custom author="auth2" limit="1" />
etc

Yiannis
——————————
neme.org | hblack.net | EMAP | NeMe @ github
I do my best editing after I click on the submit button.

Offline

#2 2022-09-19 06:28:25

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,472
Website GitHub Twitter

Re: latest article per author

Hi

May be something like this (not tested):

<txp:authors name="auth1, auth2">
<txp:article_custom author='<txp:author />' limit="1" />
</txp:authors>

Look at txp:authors doc to see how to select somoe authors by group or name list

Cheers.

Offline

#3 2022-09-19 09:10:42

etc
Developer
Registered: 2010-11-11
Posts: 4,675
Website GitHub

Re: latest article per author

The question is natural, but not the answer. Unless you want to pass the whole article list ordered by AuthorID, Posted DESC through <txp:if_different /> filter (can be long), a complex SQL query looks necessary:

<txp:etc_query populate="article" markup="db"
data="SELECT *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod FROM textpattern t1 JOIN 
(
  SELECT AuthorID, max(Posted) AS max_posted
  FROM textpattern WHERE Status >= 4
  GROUP BY AuthorID
) t2
ON t1.AuthorID = t2.AuthorID AND t1.Posted = t2.max_posted ORDER BY t1.AuthorID">
    <txp:title /> by <txp:author /> (<txp:posted />)
</txp:etc_query>

I don’t see how we could pack this monster into <txp:article /> attributes, though it’s tempting.

Offline

#4 2022-09-19 10:35:17

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,877
Website GitHub Twitter

Re: latest article per author

Thanks so much guys.

Will test this afternoon.


Yiannis
——————————
neme.org | hblack.net | EMAP | NeMe @ github
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB