12

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?

  • 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 '12 at 2:07
-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.

  • Please do not do this. There's no reason for a full node_load; it will slow down your views considerably. – aaronbauman Apr 3 '15 at 16:01
29

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.

14

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, privacy policy and cookie policy

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