Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-11-06 17:06:47
- Neko
- Member
- Registered: 2004-03-18
- Posts: 458
Select latest 10 articles, then display only 1 of them
Hi. As the title suggests, I’d like to have TXP select the latest 10 articles, and display only one of them (random).
I was playing around with article_custom but then I realized I’m not able to figure out how to achieve such a result. Any suggestion, please?
Thanks.
Offline
Re: Select latest 10 articles, then display only 1 of them
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
#3 2009-11-06 20:20:30
- Neko
- Member
- Registered: 2004-03-18
- Posts: 458
Re: Select latest 10 articles, then display only 1 of them
Matt,
first of all, thanks for your answer.
I was trying to figure out how to use smd_r_t but I was able to pull the article ID only, and I don’t know how to ask for the latest 10 articles anyway.
<txp:smd_random_text type="database"
source="textpattern|ID" limit="1"
wraptag="ul" break="li" />
Should I use that code in conjunction with other tags, such as txp:variable?
On a side note, Stef posing as Einstein is way too cool. XD
Offline
Offline
#5 2009-11-06 20:46:23
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Select latest 10 articles, then display only 1 of them
<txp:article_custom limit="10" sort="posted desc" /><txp:article_id /></txp:article_custom>
Put this inside the smd_random_text tag (probably as the source value, don’t know it) which itself is used as an article tag’s id value (with limit=“1”).
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Select latest 10 articles, then display only 1 of them
I’ve used smd_random_text with a txp:variable filled with delimeted text which could be articles.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
#7 2009-11-06 21:31:19
- Neko
- Member
- Registered: 2004-03-18
- Posts: 458
Re: Select latest 10 articles, then display only 1 of them
OK, thanks to all of you for your insightful tips.
I decided to go with Gocom’s suggestion since it’s the easier to implement, at least for me. Thanks!
<txp:article_custom section="Videogiochi, Merendine, Cavolate, Carta, Cartoni-animati, Cinema, Televisione, Giapponeserie, Animali" limit="1" offset='<txp:php> echo rand(0,9); </txp:php>' sort="ID desc">
<a href="<txp:permlink />" title="<txp:title />"><txp:article_image /></a><a href="<txp:permlink />" title="<txp:title />"><span><txp:title /></span></a>
</txp:article_custom>
You can check out the result here (the little framed picture on top right, CSS might bomb in IE).
On a side note: do you notice some flickering while hovering the mouse on the main 8 images? I get that a lot using FF/Mac. Weird, tho, since the same (static) page on the same server using the same browser looks OK to me: http://www.numerozero.it/index.html.
Last edited by Neko (2009-11-06 21:38:34)
Offline
Re: Select latest 10 articles, then display only 1 of them
I think you went with the best solution. I like it and it still looks good in IE7.
The main images have a onhover but it only works for me when I hover over the right border. If my mouse enters the image from any other side the hover doesn’t appear.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
#9 2009-11-07 22:22:43
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Select latest 10 articles, then display only 1 of them
Neko wrote:
Weird, tho, since the same (static) page on the same server using the same browser looks OK to me: http://www.numerozero.it/index.html.
Neko, the a-tags inside you h2 don’t have titles on the static HTML site (actually they’re just empty). And that’s what causes the flickering (FF3.5mac here, too): As soon as the titles vanish FF rebuilds the red semi-opaque rectangles.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#10 2009-11-08 01:38:20
- Neko
- Member
- Registered: 2004-03-18
- Posts: 458
Re: Select latest 10 articles, then display only 1 of them
Matt and Uli: thanks a bunch for the feedback. I got rid of the tiny JS code for those elements and I’m experimenting a bit with a CSS-only solution. It works fine on FF and Safari so far. No luck on IE, but the JS thing wasn’t working either so I guess it could not be considered a regression. :)
Offline