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

Idan Arbel idan at arbel-designs.com
Mon Mar 28 16:00:50 UTC 2011


Thanks,

 

But the question is how do I sort them using an argument?

If you' look here:

 

http://www.premiumbaby.co.il/koziol/drupal-7.0/%D7%9E%D7%95%D7%A6%D7%A8%D7%9
9%D7%9D

 

you'll see grid of products, each item is actually a views slideshow of
product entities of the different colors.

 

What I'm looking to achieve is to load the view with an argument that would
cause all the green products to be displayed first, or on a different page
use a different argument and have all the orange products displayed first.

 

Thanks for the idea though.

 

Idan

 

From: development-bounces at drupal.org [mailto:development-bounces at drupal.org]
On Behalf Of Justin Ellison
Sent: Monday, March 28, 2011 5:44 PM
To: development at drupal.org
Subject: Re: [development] how to use an argument to get a row to appear
first in a View

 

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
whatever.

 

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.

 

HTH,

 

Justin

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/d52b91e7/attachment-0001.html 


More information about the development mailing list