Hi,

Basically what I'm after is another field to choose from, under the Node category, which would have the path or url of the node.

Thats it! :)
Thanks!

Comments

dawehner’s picture

Version: 6.x-2.6 » 6.x-2.x-dev

I think this would have to be a prerender_list handler

mikeker’s picture

Status: Active » Needs review
StatusFileSize
new1.61 KB

I had the same need in a project I'm working on. Attached is a patch to add Node:Path as a display field. I didn't need filters or sort functionality so I didn't add those.

I would be good to include a relative/absolute option -- I'll see if I have time to add that later. In the meantime, any help testing would be appreciated.

dawehner’s picture

Mh this executes the function quite often. You could perhaps use pre_render method to load all path aliases at once.

mikeker’s picture

dereine, I'm not sure I understand. render() is called once per node:path field per record. Using pre_render to load all path aliases at once will make the same number of calls to drupal_get_path_alias. Wouldn't adding a pre_render() method add an additional function call to the total? Or is there some way to use pre_render to replace render()?

Thanks.

nevets’s picture

Why not just use the "Node: Link" field?

mikeker’s picture

Node:Link gives you the whole <a> tag with no ability to edit it (eg: add a title attribute). The use case I ran into was creating having the Node:Title link to the node with a custom field in the in the title attribute.

nevets’s picture

Then you might want to consider a patch to "Node: link" that makes that possible, it seems to make more sense than another field type.

mikeker’s picture

I considered that. I thought Node:Path would be more flexible in terms of using the "Rewrite the output of this field" in other fields. Perhaps not, though.

Also, to do this in Node:Link, I'd have to add the alt text field plus enable both that and the "Text to display" field for replacement patterns. And, to put it bluntly, I've got no idea how to do that...

I can look into it if you feel strongly that this belongs in Node:Link or that adding another node field creates additional confusion.

ao2’s picture

I am interested in this functionality too.

dawehner’s picture

Wouldn't it be possible to write a drupal_lookup_path_multiple?

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

The more i think about it, i'm ok with this patch. Even for normal links to nodes, this function will be stored and cached internally

ao2’s picture

Maybe it could be better to use url() instead or concatenating base_path() directly.

mikeker’s picture

StatusFileSize
new2.17 KB

I think ao2 is right. Besides it also makes it really easy to add an absolute/relative option, which I did with the attached patch.

allhailtheduck’s picture

The patch above works beautifully, kudos and thanks.

I'm using it with Views Gallery to link the image in the gallery teaser to the gallery node itself.

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

For me absolute should be configurable. There are use cases for both.

mikeker’s picture

Status: Needs work » Reviewed & tested by the community

For me absolute should be configurable. There are use cases for both.

Agreed. The patch in #13 adds a checkbox for absolute paths.

dawehner’s picture

Yeah the patch looks fine.

RikiB’s picture

Works perfectly, I hope this gets added soon so when I update I wont have to patch again.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Needs work

Ok, this is +1.

However, the new handler seems to be missing an option_definition() to define the new 'absolute' setting, which will break in 3.x. This is necessary.

dawehner’s picture

StatusFileSize
new2.05 KB

Update, but still needs work.

Non-Absolute urls should be "node/123" instead of "/node/123".b

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new2.18 KB

Ok. Its fine. You can use absolute then. Added a description to document this

merlinofchaos’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Needs review » Patch (to be ported)

COmmitted to both branches of 6.x; doesn't apply to 7.x but this is probably an easy fix.

dawehner’s picture

Status: Patch (to be ported) » Fixed

And commited.

Status: Fixed » Closed (fixed)

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