2

Is there any way to get this? I can get the node ID and link to a node using node/nid, but then I have to mix pretty links that pathauto gives me with ugly ones.

Is there any way to get the url alias as a field value when building a view?

Edited: My question was wrong.

  • 3
    From the question, it is unclear if you are refering to path aliases or clean urls. A clean URL is example.com/admin/config/search/clean-urls and a Standard URL is example.com/?q=admin/config/search/clean-urls. A standard Drupal path is example.com/node/1 and a path alias is example.com/content/first-page. IN each case they have different appearances but can refer to the same content. Please provide specifics regarding your view definition including the fields, path and filters to help us understand the question a little better. – Ashlar Feb 1 '12 at 4:22
17

Updated Answer for your Updated Question:

In views you will need to add one of 2 fields. 'Content: Path' is likely the one you are looking for though. Below is where to find it.

1) First you need to open your view for editing.

Open your view for editing.

2) Next, find "Content: Path" and add it to your view.

Locate and select Content Path

3) Side note - If you would like a simple link you can add "Content: Link" in stead. You also have access to Content: Edit, and Content: Delete among others.

Additional Links


Pre-update: I will update this answer if you clarify your question. Specifically what you mean by 'as a field value.'

As I currently understand your question I think this may be what you're looking for.

I believe you will need to use drupal_lookup_path() to find a path alias.

Example:

drupal_lookup_path('alias',"node/".$node->nid);

Source: Drupal Community Documentation for drupal_lookup_path()

Given an alias, return its Drupal system URL if one exists. Given a Drupal system URL return one of its aliases if such a one exists. Otherwise, return FALSE.

Parameters

$action One of the following values:

wipe: delete the alias cache.

alias: return an alias for a given Drupal system path (if one exists).

source: return the Drupal system URL for a path alias (if one exists).

$path The path to investigate for corresponding aliases or system URLs.

$path_language Optional language code to search the path with. Defaults to the page language. If there's no path defined for that language it will search paths without language.

Return value

Either a Drupal system path, an aliased path, or FALSE if no path was found.

  • I updated my question because I was confusing the terms. If I'm building a view I can't really use a function to get the path, so how would I use drupal_lookup_path()? – Joren Feb 1 '12 at 23:22
  • Updated answer to include Views solution. – Citricguy Feb 2 '12 at 0:15
  • path will include / character, Is there a way to remove this character. I want to use the path as replacement value on other field – Permana Jul 3 '14 at 1:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.