I have setup a view to output a "video" node list in a "video collection" node. The "video collection" has a CCK nodereference field refer to the related "video"s. However, I can not output the title of the video with a corrected link by using "Output this field as a link"
The views has the following setting:
@ filter: video content type
@ argument 1: Search: Links from ; Action to take if argument is not present: Provide default argument --> Node ID from URL ....this will automatically pass nid of "video collection" as argurment
@ fields: --> Node: Title; Output this field as a link checked; Link path: node/%1/[nid] ....just follow the suggested replacement below, and this should output the field with link like node/{nid of video colleciton}/{nid of Video}
However, the real output of the above fields was node/{title of video colleciton}/{nid of Video}??? The %1 returns the title from URL instead of node ID.
Is this a bug? If not, how can I output %1 as node ID???
Thanks in advance.
Comment | File | Size | Author |
---|---|---|---|
#3 | Video Playlist 2.jpg | 139.41 KB | happydrupal |
Comments
Comment #1
happydrupal CreditAttribution: happydrupal commentedMy bad...just correct to the right version.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedThis is neither a bug, nor critical. %1 prints the title version of the argument, not the raw argument. It is possible that there needs to be a method of printing the raw argument.
In your case, you can add a node: nid field, set it to 'exclude' and move it ahead of the item you want; then use that for your token.
Comment #3
happydrupal CreditAttribution: happydrupal commented@ merlinofchaos:
Thanks for the quick response. But I have to open again since your suggestion didn't work and I need support again.
This view was embedded in the "video collection" only. I did use your suggestion in Link path: node/%1/[nid] to bring out the "video" node ID as [nid] in the second argument output. But I can not use the same trick to bring out the "video collection" node ID since it was injected to the view by the following Argument setting.
I think I still need a way to printing the raw argument instead of the title version of the argument.
Attached please also find my whole idea for the view since I can find any module for this. The view we discussed here was in the lower block. The other view in the upper block uses the second argument of the output link from the the view we discussed here to display the selected video. This also related my other feature request of Panel in #471228: Is that possible to make $links from a node as a different content when doing node override???.
It's still amazing though I can use View to do such a thing. So close............................
Thanks in advance.
Comment #4
happydrupal CreditAttribution: happydrupal commented@ merlinofchaos:
I still can not figure out how to solve my problem since %1 prints the title version of the argument, not the raw argument.
Is it possible that there needs to be a method of printing the raw argument in the near future???
Thanks in advance!
Comment #5
agentrickardRight now, you need a custom argument handler, since the node handler does this translation for you.
Instead of using the argument in your view, can you instead load a hidden field and use that token instead?
Long term, here is a possible solution, which requires code.
1) Remove the custom title_query() options from the provided argument handlers.
2) Allow views_handler_argument to set the argument value based on a field replacement trick:
-- Read hook_views_data() for this argument to determine what fields can be referenced from this argument.
-- Provide a select list for choosing the field to load when using this argument.
-- Allow handlers to set default values for this selection (so NID would use node.title).
-- On title(), run a lookup query to replace the raw argument with the data from the desired field.
3) Profit!
Alternately, we could just specify a 'raw' checkbox to disable title_query().
Comment #6
kenorb CreditAttribution: kenorb commentedRelated solution: http://drupal.org/node/483036#comment-1682916
Comment #7
happydrupal CreditAttribution: happydrupal commented@agentrickard
Thanks for your response, even I can not fully understand nor help in the long term solution you suggested.
However, My view was embedded in the "video collection" only as mentioned above. I did use your suggestion in Link path: node/%1/[nid] to bring out the "video" node ID as [nid] in the second argument output. But I can not put any hidden field to bring out the "video collection" node ID since it was injected to the view by the following Argument setting.
Search: Links from ; Action to take if argument is not present: Provide default argument --> Node ID from URL
Will you kindly show me how to do that? Thanks in advance.
Comment #8
happydrupal CreditAttribution: happydrupal commented@kenorb
Thanks, I'll checking it.
Comment #9
happydrupal CreditAttribution: happydrupal commented@kenorb
I just follow your suggestion and create the TPL file of views-view-field--my_view_name--field-image-fid.tpl.php since I just want to replace the %1 from the title version of the argument to the raw argument.
That is
Find title version of the argument --> $node->title
Replace with the raw argument --> arg(1)
The code in views-view-field--my_view_name--field-image-fid.tpl.php is listed below
However, $node->title return 'null' so nothing really changed. What is the correct variable to use which return the node title of the node?
Thanks in advance.
Comment #10
happydrupal CreditAttribution: happydrupal commentedMore search then found a modification can do the trick.
Link path: node/%1/[nid] ..............remains
with a views-view-field--my_view_name--field.tpl.php in the theme folder ..... though it's trick to find the right tpl name to use
code inside the views-view-field--my_view_name--field.tpl.php
The above code will swap the %1 from the title version of the argument into the raw argument.
Thanks for all of you who pass the assistance.
Comment #11
kenorb CreditAttribution: kenorb commentedhappydrupal:
If I understand correctly by using Views argument you will have title of the node as default.
See: http://drupal.org/node/483036#comment-1682060 #5 and #6
So in your case you don't need this tpl file.
Comment #12
happydrupal CreditAttribution: happydrupal commented@kenorb
Gee..............I just figured out part the myth behind #5 and #6. :p Indeed, a simple solution is always the best solution. Thanks for reminding.
However, I still can not figure out how to load the parent id as a field as #6 mentioned??? And I had been suffered from this for these weeks. Any suggestion or help?? Thanks in advance.
BTW, in my case I had to put the nodereference field in the Parent node and used "Search: Links from" as the first Argument to find the child nodes in view. I think that's why I can not find the way to put nid of parent node for the hidden field.
Comment #13
happydrupal CreditAttribution: happydrupal commented@kenorb
Finally, I still take your method in http://drupal.org/node/483036#comment-1682916.
%1 will not only display the title version, once there's any Reserved Characters in HTML in the title it could be worse. It will return
Penny%26%23039;s Show
for "Penny's Show".That is:
Link path: node/[arg1]/[nid] ..............replace %1 with [arg1]
with a views-view-field--my_view_name--field.tpl.php in the theme folder with code below to replace [arg1] into arg(1)
Thanks anyway.
Comment #14
disandov CreditAttribution: disandov commentedHi everyone,
I've tried the soultions posted above but I cannot get them to work.
I'm a newbie, and been looking around for a solution to this issue for a long time.
I would really appreciate if someone cand help me with this.
thanks a lot.
Comment #15
happydrupal CreditAttribution: happydrupal commented@ disandov
Could you provide a more specific scenario?
The appropriate name of tpl.php should be the trickiest part IMHO.
Comment #16
disandov CreditAttribution: disandov commentedI have a block view called "top_video_block", which uses a node reference argument to show content related to the current node. Let's say i'm in node/38, then, the block shows the content wich references to that node.
I've created another view called "videos_page", which is meant to show the rest of the content which is not shown in the block. The path to this view is "node/%/videos_page"
In the block view, i added a field with the link: "node/%1/videos_page", where %1 is argument 1, which should give me te node id, but the output gives the following: "node/The%20Kooks%20en%20Chile/videos_page/". So views is using the title instead of the nid.
I made a tpl called views-view-field--top_video_block--field.tpl.php and inside wrote this code:
but it is still not working...
I'm kind of lost at this point and don't know what to do.
I would really appreciate your help.
Thanks,
D.
Comment #17
happydrupal CreditAttribution: happydrupal commented@disandov
Try http://drupal.org/node/483036#comment-1682916.
Comment #18
disandov CreditAttribution: disandov commented@happydrupal
thanks for your help
I think you were right... I think i'm not using the right tpl.php name
My view is named top_video_block
i tried using the name: "views-view-field--top_video_block--field.tpl.php" but it didn't work.
i'm putting the link in a field called Global: Custom Text
could you give me a hint on how to write the tpl.php name correctly?
thanks.
D.-
Comment #19
happydrupal CreditAttribution: happydrupal commented@disandov
Try "views-view-field--top-video-block--field.tpl.php". Hope this helps..............
Comment #20
disandov CreditAttribution: disandov commented@happydrupal
Still having no success...
I even cloned the view and named it "topvideoblock" in order to discard any possible confusion with "-" or "_"
Shouldn't this issue be common? Maybe there's another way to do what I want.....
Comment #21
happydrupal CreditAttribution: happydrupal commented@disandov
Yeap, Help text in Views mentioned that
The active template for each plugin -- which is the most specific template found on the system -- is highlighted in bold.
As far as I know, the theming information in Views will not map your tpl.php in BOLD sometimes. But it really works!!!======================================================
updated on 6/27
Make sure you didn't use the alternative Admin Theme first before you check the Theming information. Otherwise, you'll never find your template highlighted since there's no such template in your alternative Admin Theme folder.
Comment #22
disandov CreditAttribution: disandov commented@happydrupal
it worked!! you were right. The right template was highlighted in bold, in the "Theme: Information" settings under "Basic Settings" in the Edit Views Page. Of course, i had to Rescan Template Files before it worked.
thanks a lot,
D.-
Comment #23
merlinofchaos CreditAttribution: merlinofchaos commentedI just checked a fix into Views dev that will allow you to access the raw argument input via !1 (paired with %1 to get the argument title).
Comment #24
kenorb CreditAttribution: kenorb commentedThanks!
Comment #25
happydrupal CreditAttribution: happydrupal commentedOH..............Great thanks!!!
Comment #27
joerns CreditAttribution: joerns commentedThanks a lot!