Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Sort articles by date
hello TXP community!
as a TXP newbie i spend the last few days reading a lot of tutorials and tips but i’m a little stuck now.
i’m trying to replace my old self made CMS with textpattern. i wrote a php-script to import my (+10.000) articles to the textpattern DB and automaticly renamed all current pictures to work TXP. this worked fine but i’m still having troubels with the article sorting. i plan to use TXP for an online magazine and this is what i want to achive:
-> show on the startpage only articles from the latest updates (e.g. 01.11.2008)
-> if there are not enough articles to display from the “lastest update” (e.g. 15 articles) i would like to fill the gap with articles from a previous update
my current approch is a little hackish…
<code>
<txp:php>
$lastUpdate = searchQuery(“SELECT count(*) AS count FROM textpattern GROUP BY DAY ORDER BY Posted DESC LIMIT 1”); ($lastUpdate[‘0’][‘count’] > 15) ? $GLOBALS[‘limit’] = $lastUpdate[‘0’][‘count’] : $GLOBALS[‘limit’] = “15”;</txp:php>
<txp:article sort=“Posted desc” limit=’<txp:php>echo $GLOBALS[‘limit’];</txp:php>’ />
</code>
since TXP is such a flexible CMS i guess this could be done via TXP tags – maybe someone could point me in the right direction ;-)
THX a lot for any tips!!!
Superfly
<code>is</poetry>
Offline
Re: Sort articles by date
hi superfly
why not making <txp:article limit=“15”> ?
the tag will output the last 15 newest articles by default!
Cheers
Offline
Re: Sort articles by date
hey Dragondz,
thx for the reply…
problem is that my authors post on some days more then 15 articles and on some days less then 15 – and i need to show ALL articles for a day. only if the numbers of postet articles/day is under 15 i need to pull some old ones… :-S
i hope my explanation is not to weird – i’m no native english speaker ;-)
<code>is</poetry>
Offline
Re: Sort articles by date
Hi again
Maybe chh_article_custom plugin can help you website link
But that not solve all the problem!
NB: I am not native english speaker too!
NB1: the problem here is to count the number of articles, i haven’t the solution in my mind, but maybe using the new txp tag txp:variable can help
Last edited by Dragondz (2008-12-02 11:15:11)
Offline
Re: Sort articles by date
hi dargondz,
that plugin looks interessting but it didnt helped me any further – but i keep it in mind maybe someday i’m gonna need ist.
the new txp tag txp:variable is a great help and makes TXP even more flexible. is there a method to check if a txp:var is e.g. greater as “>”? cause as far as i read it can only check if the var is set or if the var has a speficic value eg. <txp:variable name=“foo” value=”“ /> or <txp:variable name=“foo” value=“bar” /> but
<txp:variable name=“foo” value=”>15” /> will not work or did i miss something?!
<code>is</poetry>
Offline
Re: Sort articles by date
superfly wrote:
is there a method to check if a txp:var is e.g. greater as “>”?
Not built in; it only does equality or set/unset. For everything else you need a plugin and — if I may be so bold — if you are comparing things like txp:variables or url vars to other things in your article, smd_if is hard to beat.
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: Sort articles by date
cheers bloke!
thx very much for the tip, i will check that plugin out – looks promising. i will for sure run in the situation where i can need it.
<code>is</poetry>
Offline
Pages: 1