Community Documentation

Some use cases of Arguments

Last updated January 23, 2008. Created by Rob Loach on January 6, 2008.
Edited by greggles, kyl191. Log in to edit this page.

Sorting a list of nodes based on the author's name (for a blog-like display)

In a nutshell:

URL: blog/author/$arg
Argument: User: Username is author
Title: Posts by %1
Wildcard: all
Wildcard Sub: all users
In a nutshell
Larger version

The output of the view will change dependent on the URL (see one author and every author (using the wildcard))

Posts by all users

Note that the title has also changed - this is because of the '%1' in the 'Title' option under the Argument Options. In the case of the wildcard being using, the text entered in 'wildcard sub' in used in place of '%1'.

Displaying a list of nodes based on the month and year of creation:

In a nutshell:

URL: node/date (note the absence of $arg - If it doesn't appear in the URL, it's not necessary for the user to include it)
Argument: Node: Posted Year and Node: Posted Month
Title: "Posts made during %1" and "Posts made during %2 %1" respectively
Wildcard: * for both arguments
Wildcard Sub: "all years" and "all months" respectively
In a nutshell
Larger version

The output of the view will change if the user enters a particular year/month combination for the URL.

For example, entering 2007/12 as the date will give this:
Selecting posts posted in December 2007

(You can also see Selecting nodes posted in 2007 vs. Selecting nodes posted in 2008 and selecting nodes posted in November 2007 vs. selecting nodes posted in December 2007)

This view can also return all nodes posted within a certain month by making use of the wildcard for the year argument.
Selecting posts posted in a certain month
(Full screenshot)

Sorting a list of nodes by the most recently commented on/newest posts

In a nutshell:

URL: node/recent/$arg
Argument: User: UID Authored or Commented
Title: Recent comments on posts and new posts by %1
Wildcard: *
Wildcard sub: all users
In a nutshell
Larger version

Combining arguments with sort criteria can give you some pretty nifty views. This particular view, when combined with sort criteria like "Comment: Last Comment Date" and "Node: Created Time" will sort the nodes that fulfill your arguments based on the most recently posted/commented node.

Sort criteria

Recently posted/ commented on nodes

The argument will return nodes posted by or commented on by the user with the uid specified in the URL.
Only posts/comments made by the user with that uid will be returned.

Generating an RSS Feed of your view

In a nutshell:
URL: blog/author/$arg (The RSS Feed argument doesn't need $arg. Just append '/feed' to any views URL with the RSS Feed argument, and you'll be given an RSS Feed page.)
Argument: RSS: RSS Feed Selector
Title: Posts by %1
Option: RSS Feed provided by Views
Wildcard: *
Wildcard Sub: all users
In a nutshell
Large version

This view is essentially the same view as "Sorting a list of nodes based on the author's name", which one argument added: the RSS Feed Selector. The RSS Feed Selector argument essentially gives you an RSS Feed of your view.
RSS Feed of posts by a certain author

Of course, change an argument in the URL, and the RSS Feed correspondingly changes.
A changed URL

(Using wildcards also works in this scenario.)

Comments

Drupal 6

I would appreciate an equivalent for Drupal 6/Views 2.

About this page

Drupal version
Drupal 5.x

Archive

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.