Within "Link Settings" if you have 'Link the title to the node' = 'site' and 'Enable click-tracking' = 'yes' the url to go to a site should be weblinks/goto/n. This is correctly shown when a link is viewed on the main links page but but when displaying in a group we get weblinks/weblinks/goto/n which produces 'page not found'. The url is probably being defined as relative to the page it is on, so it works at the top level but fails when viewed in a group such as /weblinks/tid.
Also when the Drupal site does not have 'clean urls' enabled the title link fails because it does not contain the required ?q=
[I know I said that we'd not create any more 7.x blocker issues, but this is important enough. We can't release 7.x with known bugs which produce '404 page not found' links within our own generated content. I will work on this]
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2463501_2.fix_link_url.patch | 1.2 KB | jonathan1055 |
| #2 | 2463501_2.fix_link_url.patch.debug_.txt | 5.33 KB | jonathan1055 |
Comments
Comment #1
GStegemann commentedI could reproduce that as well.
Sure, this is a 7.x blocker issue. Thanks.
Comment #2
jonathan1055 commentedI've worked out what is happening and luckily the solution is simple, but here are my full notes, for reference:
The setting 'link the title to the node' is controlled by variable
weblinks_title_link, 1=node, 0=site. Default is TRUE(1) = nodeThe setting 'enable click-tracking' is controlled by variable
weblinks_redirectThere is potential for confusion, because the admin setting variable 'weblinks_title_link' is also the name of the node property $node->weblinks_title_link which holds the actual url to go to.
weblinks_weblinks_preprocess() calls weblinks_node_view.tpl.php. Then we get weblinks_preprocess_node() which has $variables[node_url] as the value set in .tpl.php. It is this $variables[node_url] which is used behind the node title, via node.tpl.php
weblinks_node_view.tpl.php generates the link to display the site's url, and when click-count enabled (variable weblinks_redirect is true), the value is
$node->weblinks_title_link = 'weblinks/goto/'. $node->nid;. This is the correct raw url and produces the correct href for the actual weblink site (as written in the .tpl) because this also uses l(). But the same $node->weblinks_title_link value when reused later behind the node title gets the wrong final value because it is relative to the current page. Adding url( ) around the value fixes it for all conbinations of click-track on/off and link to site/node. I have also tested it with clean urls not enabled and when Drupal is installed in a subdirectory.Attached are two patches, one with full debug, where the links are manipulated to see what is being done. The second patch is a clean fix of the code.
Comment #3
GStegemann commentedTested and works. Good, that sometimes things are simple to fix.
Yes, I also had difficulties to understand the code. Thanks for your added detailed comment.
Comment #5
jonathan1055 commentedThanks for testing.
Yes, after I have done any indepth analysis of a bug, it is worth recording the details here, and adding a few more comments to the code.