15

In views I need to return the raw url that is provided as the href value to the title field (when as a link) or the Content: link value. I thought originally I could choose Content:link and strip the HTML in a rewrite, but no go.

I need the full URL so that I can pass it as a parameter in a field rewrite. Thoughts on how to get this only?

1
  • 2
    The url to node based content can always be accessed as node/NID, so, you should be able to have Node: Nid as a field and then use it in a rewrite later on as node/[nid] or something similar.
    – Jimajamma
    Jul 18, 2012 at 2:07

4 Answers 4

-3

There is number of ways you can do this but the following is fairly easy.

In your view add NID as a field.

Create a 'row style' template that loops through the $fields object.

In your template file, before the loop assign a variable with the NID value from the field.

$nid = strip_tags($fields['nid']->content);

Then use the node_load() function to load a node object.

$node = node_load($nid);

You should be able to access anything you want including the path from this node object.

To see whats in it use Devel if you have this installed or just use the PHP var_dump() function.

Even better check whether you have a 'path' field the you can add.

1
  • Please do not do this. There's no reason for a full node_load; it will slow down your views considerably. Apr 3, 2015 at 16:01
32

As per the comment here http://drupal.org/node/458316#comment-6236984

In views 3.x you can use "Path" field with option "Use absolute link (begins with "http://")" in Rewrite results section.

2
16

Yes, we can use the path field. This also support multilingual content. Please find attached screenshot to see what it looks like.

enter image description here

2

Adding to rakesh.flake comment, we have a option to add the absolute URL as well in the settings.enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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