Return Node Title for use in Views Argument

Events happening in the community are now at Drupal community events on www.drupal.org.
thepocketgeek's picture

What would be the simplest way to pass the Node Title to a view that is going to use that title as part of an argument? I only want the view to return an image that is part of that particular node. Right now all of the node images are showing up.

If I provide the default argument, can I use the [title] field that I am using when I rewrite the output or is there a php variable that I need to use?

Comments

You want to use the node ID

garethsprice's picture

You want to use the node ID rather than the node title if you're using it to look up a node. Node IDs are constant and easy to do database lookups on, titles can easily change, are not unique, and may contain non-alpha characters which will make it difficult to search (eg. "Who's?: Gareth's" would render as "Whos Gareths" if run through an alpha-only filter, and a database search on that title would not match).

When you add a Node ID argument, under "Default Value" you can set "Get node ID from URL".

Orlando, FL Web Developer | http://www.garethsprice.com/

Okay. It will still be able

thepocketgeek's picture

Okay. It will still be able to pull the Node ID even if I am using PathAuto, correct? I will try that.

Thanks.

Yes, pathauto's translation

garethsprice's picture

Yes, pathauto's translation happens further up the rendering stack, so you can still use node/[nid] arguments in Views as by the time your data hits the view, the URL has been translated back to the node/[nid] format.

In fact, you should rarely (never?) use pathauto-translated URLs internally, most stuff (with the exception of body text fields) will automatically rewrite node/[nid] style URLs to their pathauto equivalents for display.

Orlando, FL Web Developer | http://www.garethsprice.com/

Florida

Group organizers

Group categories

Florida Topics

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: