Hello,

I've been trying to setup 'Output this field as a link'... the problem i'm confronting with is that it supports only absolute path urls, so adding a default variable as [base_url] would be great. I would like to modify the views module to support this default variable but i want to make sure the changes will be commited in the upcoming releases of the module.
I never modified anything inside the drupal official development so i really don't know who to contact (a maintainer perhaps), will the patch go trough ?

Thanks,
Iosif

Comments

dawehner’s picture

Priority: Critical » Normal

if you created your patch you should upload the patch to this issue and the the status to needs review.
Then other people test the patch, look for codestyle and give opinions about the patch and then the maintainer will commit it if its ready and fine

Anonymous’s picture

Category: feature » support

Is there a list of variables that do work in here? Or an example somewhere?

I would like each to link to their own node id $nid (like the Title field has the option for doing).

dawehner’s picture

Category: support » feature

sry but do not hijack issues

Anonymous’s picture

I'm sorry Daniel.

I thought that I did the right thing in searching for a relevant issue/post first using the module's search function, and upon finding it, posting my questions.

It wouldn't have been too hard to say 'hey, what you are wanting is here.....' and provide the url though, eh?!

dawehner’s picture

you can rewrite the output as link

doknet’s picture

Title: Views links relative paths » Views links as absolute path

Hello
Sorry but this topic is close to what I'm looking for
Wonder how I can make out path as absolute and not relative
Instead node/31 output www.ejemplo/node/31
view ----- field ---- nodo:link
excuse my English

EvanDonovan’s picture

Title: Views links as absolute path » Add option to create Node:Link field as absolute path
Version: 6.x-2.0 » 6.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new1.14 KB

I have changed the code of views_handler_field_node_link.inc to accomplish this (by adding an option called "Use absolute path" to the field handler).

Please review the attached patch.

EvanDonovan’s picture

Component: Miscellaneous » node data

Changing component.

dawehner’s picture

Status: Needs review » Needs work

There is missing quite a lot.

1. you could to this in views_handler_field
2. Codestyle, for example

+    if($this->options['absolute'] == FALSE) { return l($text, "node/$nid"); }
+		else { return l($text, "node/$nid", array('absolute' => TRUE)); }
   }
EvanDonovan’s picture

Thanks for the review.

1) I'm not sure what you mean by doing it in views_handler_field? Isn't that a more general case, and so it would provide the options for fields that weren't actually links at all? This is only the second thing I've ever coded for Views 2, though, so I really don't understand it that well yet.

2) I realized after the patch was submitted that the formatting was way off. But I figured a patch for the issue (which I've tested to work) was better than nothing.

dawehner’s picture

Every field has currently the possibility to be outputed as field. So you would have to patch handlers/views_handler_field.inc

Then perhaps some users want the absolute feature for every kind of field.

Sure a patch is better then nothing, but especially for other people trying to understand the code its much much better to have good codestyle, so they can think in php ;)

EvanDonovan’s picture

So I guess I should use spaces instead of tabs when coding? That just takes a little longer, imo - since Dreamweaver handles tabs automatically but not spaces. But I'll try to do that from now on.

I still don't see how the absolute URL feature would work on all fields, because not all fields are link fields, and this feature takes advantage of a parameter of the l() function. It wouldn't make sense to have an absolute Node:Body for example :)

dawehner’s picture

You can confire each field with "output as link". Then you definitive have a link.

EvanDonovan’s picture

Oh, OK. Now I understand. I'll have to see how it could best be implemented then.

neilnz’s picture

I'm interested in this support as well - I'm using the fb module to output views inside a Facebook app, so need node links to be absolute so they return back to the home site rather than http://apps.facebook.com/node/1234, which doesn't work so well :)

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.77 KB

Here is a first general thing.

I have no time to test, because my latop is running out of battery :(

'html' => 'true',

Is it just me thinking: WTF

But this will currently not what you wanted to do

neilnz’s picture

Status: Needs review » Needs work

That patch doesn't seem to work properly. When I tick the absolute link option, after saving the field it unchecks itself again. Also, it doesn't make the link absolute either...

josepvalls’s picture

Any updates on this?

Very interested. Also for Facebook.

I was trying to hack render() in views_handler_field_node_link.inc but didn't work. I cleared all the cache tables.

EvanDonovan’s picture

My patch in #7 works; it's just not the best way to do it :)

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.56 KB

This patch works now

EvanDonovan’s picture

I don't think I'll actually have time to test this until I get back from the conference. I'll try to test it shortly though.

djac’s picture

Status: Needs review » Reviewed & tested by the community

I had a field which I was outputting as a link under one of my view's displays. The display happens to be an iCal feed. The link was being outputted as a relative URL, but I want an absolute URL.

I tested this patch using the above field and all looks good. Instead of relative, I now get an absolute URL.

One detail: I had to change the field format from Title(link) to Title(no link).

This patch passes my tests and looks good to go.

rachelf’s picture

I've attempting something similar. I have a view and I want an image to be output as a link, using a replacement string which takes the external link from another field from that page type. Again, I was getting a relative URL instead of an absolute URL.

I have applied the patch, which gave me the tick box to select 'Use absolute path' but I still got a relative URL in my view output.

However, I don't understand the additional change I was to make "One detail: I had to change the field format from Title(link) to Title(no link)."

Please excuse my ignorance, but where do you need to make this field format change?

Many thanks.

djac’s picture

"...where do you need to make this field format change?"

Hi rachelf,

When editing a view, under the Fields section, click on the field you're looking to modify.

In my case, the field had a "Format" drop-down that allows you to select a format for the given field. Some fields have a format drop-down and some don't.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.