Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-3.x-dev
Component:
node data
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
22 May 2009 at 11:41 UTC
Updated:
24 Jun 2010 at 06:00 UTC
Jump to comment: Most recent file
Comments
Comment #1
daemon commentedComment #2
merlinofchaos commentedthe plain path...of what?
Comment #3
daemon commentedSorry, to a node.
For example I would like to list the most recent articles in this manner:
Comment #4
merlinofchaos commentedYou can add the 'nid' field and set it to exclude from display. Then you can refer to it with a token in the 'make this a link' field, or look for it in the result array if creating the link through theming. Then you can form the url like this: node/[nid]
Comment #5
daemon commentedWhat if I am using URL Aliases (Path and PathAuto), I will need to work it in the theme as well?
Comment #6
merlinofchaos commentednode/NID will be automatically converted to the alias for you.
Comment #8
Michsk commentedIf got the same thing now, and ok when you use node/nid it redirects you to the right url. But i want my seo right so i want the paths to be as they are supposed to be.
Comment #9
mshepherd commentedI agree, it would be good from an SEO point of view to get this working a little more cleanly.
I've used views to make an accessible nodes listing page. See http://vacdirectory.illuminateweb.org.uk/index
The node title in the list points to the URL alias (/org/org-name) and the 'more' link points to the node using the technique in #4 (/node/xxx). I've changed the link text (to be more accessible) using the same technique. However, it frustrates me that the 'more' link does not use the aliased path.
Would it be possible to expose a Node: Url field, along with the Node: Nid, Node: Link, Node: Title, etc?
Comment #10
mshepherd commentedMarked this closed again.
I tried with a more recent version of views and was able to customise the link stuff a bit more. See attached image. The way I did it before output a link (like /node/123) that didn't get translated to an aliased path by Drupal. This works perfectly now.
Really nice to be able to create properly accessible links like this!
Many thanks!
Comment #11
Michsk commentedHere is how to do this.
Download and install:
http://drupal.org/project/views_customfield
In your view field ad the:
Customfield: PHP codePaste this in the textarea:
ps: or you can use the post above this one.
Now you can use this for advanced themeing or just as a text link.
Comment #12
merlinofchaos commentedNot sure why this is reactivated. From what I can read this is effectively fixed and working, right?
Comment #13
mshepherd commentedYes, I had it working a treat! :)
Comment #15
maijs commentedI see that there is no "URL to the node" field in Node module of Views. And I see that there are cases when one needs to display a plain URL to the node instead of a link to the node. (I personally need it for a custom Views RSS plugin which maps fields to appropriate RSS tags where permalink to the node is a must.)
I think that URL is pretty standard piece of data that one expects to display along with the node nid, title, body, etc.
Here is the patch against Views 6.x-2.7 which adds new field "URL" under Node group in fields. Feedback is welcome.
Comment #16
dawehnerSome minor codestyle problems. Just have a look at the documents: no tabs etc.
You can do this in a single line with ? :
I guess than this would be somehow easier to read
Wouldn't it better to name it URL of the node, for me this does make more sense.
Comment #17
maijs commented@dereine: Thanks for the comments. I've modefied the patch, fixed codestyle problems and made code more readable, changed description to "The URL of the node." as you suggested. Also, I've diffed it against -dev version.
Comment #18
maijs commentedComment #19
figover commentedI tested this patch, but this error is coming
"
$ patch -p0 < views-node-url-field-470018-17.patch
(Stripping trailing CRs from patch.)
patching file views/modules/node/views_handler_field_node_url.inc
(Stripping trailing CRs from patch.)
patching file views/modules/node.views.inc
patch unexpectedly ends in middle of line
Hunk #2 succeeded at 669 with fuzz 1.
"
Comment #20
maijs commentedfigover, are you patching against current -dev version and within the directory where views reside?
Try:
download current -dev version to ./modules
move patch file to ./modules
$ cd ./modules
$ patch -p0 < views-node-url-field-470018-17.patch
Works for me, just double checked.
Cheers
Comment #21
figover commentedmaijs, I have downloaded views-6.x-2.x-dev . and i placed patch at sites/all/modules location.
But still i am watching the same error.
"
$ patch -p0 < views-node-url-field-470018-17.patch
(Stripping trailing CRs from patch.)
patching file views/modules/node/views_handler_field_node_url.inc
(Stripping trailing CRs from patch.)
patching file views/modules/node.views.inc
patch unexpectedly ends in middle of line
Hunk #2 succeeded at 669 with fuzz 1.
"
I am using cygwin for patch commands.
Patch is working fine. But i am worry about the error which is coming when i import patch.
It is very good patch according to SEO point.
Please do some more work to eliminate the error.
Thanks
Comment #22
figover commentedmaijs, here is another error.
When i reverse the patch, node url option is still coming in view.
It should not come, when i reverse this patch.
Thanks
Comment #23
figover commentedThis error run away when i clear cache
Comment #24
maijs commentedfigover, glad you have resolved your issue.
Comment #25
dagmar@maijs: I have reviewed your patch and I think that is not correct.
In first place, there is an existent node link field into views/modules/node I don't know if it correct create another handler to manage this feature.
In second place, maybe is better a single checkbox than a select box with two options.
I have modified your patch to make it work with views/modules/node/views_handler_field_node_link.inc the current handler for node links.
And since views_handler_field_node_link_edit and views_handler_field_node_link_delete inherit from views_handler_field_node_link, I have also modified this handlers to support this new feature.
This patch is incompatible with this #648484: Node Links: rewrite output doesn't respect node access levels so, if one gets committed, we have to reroll the other.
Comment #26
maijs commented@dagmar, I tested your patch and for what it does, it works fine.
However you have misunderstood the purpose of my patch. It was not created to generate absolute URL for the link to the node rather than it was made to output the URL of the node. Currently there is no way Views can output a plain URL of the node (I repeat, not a link with title "view" or "read more", just an URL) without creating a template which also has to scrub the anchor to fetch the URL.
It seems unintuitive to use Node Link handler to output an URL therefore I created an extra handler.
As for #648484: Node Links: rewrite output doesn't respect node access levels, should user be validated against content access permission before displaying an URL? I don't see any validation upon outputing Nid or Title of the node. How URL is different?
Comment #27
dagmarYes, sorry, I didn't interpreted your problem.
You can use Views Custom Field with this code:
Ok, I don't know if this is really usefull, since you can use the above code to display your link. Also I'm not really sure if my patch should be added to views. By now I'm changing the name of the issue, and changing the status.
Comment #28
maijs commented@dagmar, using Views Custom Field is certainly an option although an ugly one. The URL of a node is pretty standard stuff you would expect to retrieve about the node, along with Nid, Title, etc. In my opinion it would be much better to have
views_handler_field_node_urlas a parent class forviews_handler_field_node_link,views_handler_field_node_link_editandviews_handler_field_node_link_deleteas they all have everything to do with the URL in the end. Providing an option to turn URL to a link is a much simpler workflow rather than way around.Given you see my point and initial problem, do you still think that patch in #17 is not correct (as you stated in #17) and is incompatible with #648484: Node Links: rewrite output doesn't respect node access levels? To the technical point, I made it inherit from
views_handler_fieldrather than fromviews_handler_field_node_linkon purpose as views_handler_field_node_url has nothing to do with "links".Cheers
Comment #29
dagmarMarking #465986: "Output this field as a link" doesn't work with "Node:Link" token as a duplicate.
@mais, can you review this patch http://drupal.org/node/465986#comment-1780982 for this issue. I think is a better approach than create a new handler. Maybe we can provide a merge between #25 and #465986-7: "Output this field as a link" doesn't work with "Node:Link" token
Comment #30
maijs commented@dagmar, will look into it. Avoiding new handlers is certainly a good thing.
Comment #31
maijs commented@dagmar, I've looked into both patches and merged them both:
1. Added two option definitions to views_handler_field_node_link: absolute_url and raw_link (the same that was made in #25 and in #465986-7: "Output this field as a link" doesn't work with "Node:Link" token);
2. Added if statement in render() to check for both options (absolute_url and raw_link);
3. In these files changes were made:
Comment #32
dagmar@maijs looks good, however the patch doesn't apply, you should create the path inside the views module directory.
From: http://drupal.org/patch/create
This review is powered by Dreditor.
Comment #33
figover commentedIt is a very good feature. We should add this feature in Views modules.
Comment #34
maijs commented@dagmar, thanks for the note regarding the diff command. Point taken.
I've created another patch with guidelines followed.
Cheers
Comment #35
maijs commentedI've checked the grammar in option form element description and added this at the end of raw_link description line: '"Text to display" field value will be ignored.'.
Use this patch.
Comment #36
dagmarNice job!, ok, I tested it and it seems to be working fine. However probably raw options for edit and delete links are not very useful. See attached image.
I think this patch should provide:
Link view: Node (absolute, raw)
Link edit: Node (absolute)
Link delete: Node (absolute)
Unless you have a valid use case for this options....
Comment #37
maijs commented@dagmar, you have a point. I don't really see an use case for raw links for administrative links (delete, edit, revert) just like I don't see the need for absolute URL for these links either. But, as absolute and relative attributes are essential to links in gerenal, I agreee those should be included.
Removed raw link option from link delete, link edit, revision delete, revision revert.
I wonder whether that would be the case with comments links also...
Comment #38
dagmar@maijs Yes, absolute and raw url comments would be useful too. Can you include it into your patch?
Comment #39
maijs commented@dagmar, I will look into it.
Comment #40
maijs commented@dagmar, as I'm currently not using comments on my site, I will postpone patching comments handlers until I have some spare time. Sorry.
Comment #41
dagmarOk, I wasn't too hard. Here is a new patch including absolute url for comment links and only raw url for view comment links.
Comment #42
maijs commented@dagmar, it's allright although you've forgotten to alter views_handler_field_comment_link_delete.inc therefore delete links were not affected. I've added absolute_url option to comment link delete handler. I've also changed the order of functions in comment_link_reply handler as options_form() traditionally comes before render(). It's wise to keep consistency. Otherwise the patch is the same.
Comment #43
dagmarLines 247 and 277 contains a few whites spaces. But this works fine.
Nice work!.
Comment #44
merlinofchaos commentedHmm. This uses l() rather than converting it to the advanced_render() form of using link rewriting. Maybe this should be a global flag in link rewriting?
Comment #45
damienmckennaSubscribe.
Comment #46
merlinofchaos commentedMoving to needs work based upon my l() comments.
Comment #47
lennart commentedWith the jump menu an url alias field would be nice because the node/[nid] is not aliased when jumping in from the jump menu (from ctools)
Comment #48
dagmarLets remove this issue from the alpha 2 blocker, and fix it in this issue #669636: Re-structure all links handlers to support advanced rendering of links
Comment #51
dawehnerThis is called fixed. Because of the issue linked by dagmar