Link Node as Direct Link


Well-known member
At at the moment, link nodes work via a re-direct, rather than directly linking in the source. There are lots of benefits to that, however I'd like to link directly on one of our sites.

I had a look at the node_link_level_2 template and it looks like it uses a xen:link helper:

<h3 class="nodeTitle"><a href="{xen:link link-forums, $link}" data-description-x="#nodeDescription-{$link.node_id}">{$link.title}</a></h3>

I thought that the $link variable would have the raw URL available, but when I dump all the vars available in that template I am left with the following:

array(25) {
  ["node_id"] => int(39)
  ["title"] => string(17) "Forum Title"
  ["description"] => string(70) "Forum Description."
  ["node_name"] => NULL
  ["node_type_id"] => string(9) "LinkForum"
  ["parent_node_id"] => int(3)
  ["display_order"] => int(6)
  ["display_in_list"] => int(1)
  ["lft"] => int(64)
  ["rgt"] => int(65)
  ["depth"] => int(1)
  ["style_id"] => int(0)
  ["effective_style_id"] => int(0)
  ["breadcrumb_data"] => string(161) "a:1:{i:3;a:7:{s:7:"node_id";i:3;s:9:"node_name";N;s:12:"node_type_id";s:8:"Category";s:5:"title";s:9:"Community";s:5:"depth";i:0;s:3:"lft";i:51;s:3:"rgt";i:70;}}"
  ["discussion_count"] => int(0)
  ["message_count"] => int(0)
  ["hasNew"] => bool(false)
  ["privateInfo"] => bool(false)
  ["childCount"] => int(0)
  ["last_post_id"] => int(0)
  ["last_post_date"] => int(0)
  ["last_post_user_id"] => int(0)
  ["last_post_username"] => string(0) ""
  ["last_thread_title"] => string(0) ""
  ["lastPost"] => array(5) {
    ["post_id"] => int(0)
    ["date"] => int(0)
    ["user_id"] => int(0)
    ["username"] => string(0) ""
    ["title"] => string(0) ""

I can't see the raw URL available anywhere for me to use in the template. Is there another way to find this variable?
Unfortunately only the xf_node record is made available to the template. The xf_link_forum record is not used until it gets to the controller.

What you would need to do is extend the LinkForum NodeHandler and implement the getExtraDataForNodes() method. You can see the Forum NodeHandler as an example - this is how things like the discussion_count and other stats make their way into the node list despite being part of the xf_forum record.
Thanks Chris, I'll have a look at the code now and see if it's something that I can code :).
Top Bottom