Hi!
Is it possible with views to have a block that shows only one node (of a defined node type) from the latest 10?
On the front page I want to show this block so there is new/different content every time but never very old content. If I'd just use the random sort criteria it would also show years-old posts. New nodes of this type will be added on an irregular basis, so I can't filter the view by post date.
I'd be grateful for any hint.
Well, you can make a view that orders by creation date and shows 10, then, in the .tpl.php for the view (views--view-name_of_view.tpl.php), you can change the display to only show a random element of the array of items.
That's just one way of creating it, though. You could set your block to run php, run the view programmatically (views_get_view(viewname)), and get the info that way, and get a random entry. Of course, that causes some security issues of actually turning on php.
You could get one of the modules that allow you to enter php into the view, and that will do it, too. Or in the footer of the view you could show PHP, and have it get the values and edit them.
I hope that helps.
Joel
-----Original Message----- From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of steeph Sent: Thursday, March 01, 2012 3:21 PM To: support@drupal.org Subject: [support] View with one random of the latest 10 posts
Hi!
Is it possible with views to have a block that shows only one node (of a defined node type) from the latest 10?
On the front page I want to show this block so there is new/different content every time but never very old content. If I'd just use the random sort criteria it would also show years-old posts. New nodes of this type will be added on an irregular basis, so I can't filter the view by post date.
I'd be grateful for any hint. -- [ Drupal support list | http://lists.drupal.org/ ]
On 01.03.2012 23:44, Joel Willers wrote:
Well, you can make a view that orders by creation date and shows 10, then, in the .tpl.php for the view (views--view-name_of_view.tpl.php), you can change the display to only show a random element of the array of items.
Thanks! I think that will do it.
If there's a module to do the same, I'd rather use this. But using the .tpl.php file should work, too.