[development] how to use an argument to get a row to appear first in a View

Justin Ellison justin at techadvise.com
Mon Mar 28 15:44:05 UTC 2011

I had a similar requirement recently, and came up with what I thought was a
pretty slick way to do it.

My requirement was that a list of nodes needed a variable-sized list of
"sticky" nodes that would float to the top of the list.  The sticky list
needed to be able to be manually sorted by content admins.  Any slots in the
view not filled by the sticky list could be filled with a "most recent" list
of nodes.

The answer is to use nodequeue to create the sticky list.  In the admin
options for node queue, there's an option to display the list in reverse,
select that.  When defining your view, define your first sort order as the
nodequeue position descending.  Set your second sort to be create date or

The key is that any nodes not part of the nodequeue will have a position of
NULL, and will naturally float to the bottom of the results.  If the view is
set to display 10 results, and the nodequeue is 6 items, then the remaining
4 items will be filled with the most recent nodes.  If a content admin
changes the nodequeue to be only 2 items, the remaining 8 will automatically
fill in.

This approach might be a bit overkill for what you're doing, but it will
certainly work, and will give you some room to expand.



On Mon, Mar 28, 2011 at 10:30 AM, John Fiala <jcfiala at gmail.com> wrote:

> On Mon, Mar 28, 2011 at 9:03 AM, Idan Arbel <idan at arbel-designs.com>
> wrote:
> > Hello,
> >
> > I have a views slideshow, and in some cases I’d like a certain node to
> > appear first in the order, I don’t really care about the rest of the
> nodes
> > just to move a certain node to be first in the slideshow.
> >
> > I’m looking to achieve this using an argument, maybe sending in the nid,
> or
> > even better a certain value for another field.
> >
> Hm.
> Well, if you've got no pager, here's an idea:
> You've got two displays - one display (the main one) which displays
> one item, and a second display that displays the rest.  Display one is
> set up to display only the node provided via the argument, so that's
> automatically first.  The second display is made into an attachment on
> the first display, which inherits the same argument, only on the
> second display the argument defines the node that isn't displayed.
> The tricky thing is the way you're displaying them as a grid - that
> may not work with having the page split into two views without a lot
> of work with css and/or alternate view templates.  It might be simpler
> to have a 'grand' display of the argument node on top of a grid
> showing the rest of them.
> --
> John Fiala
> www.jcfiala.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110328/5210959d/attachment.html 

More information about the development mailing list