I just upgraded my version from alpha3 to the latest dev and in my view where I have the functionality of Output this Field as a Link, the link no longer exists.

I was using a pattern of "deals[path]/[nid]/info"

When I change it to link this field to its node, that works, but that is also not what I want.

Comments

dawehner’s picture

Assigned: Unassigned » dawehner
Status: Active » Postponed (maintainer needs more info)

Can you make a reusable views export? I will use git bisect to find the eval commit

ayalon’s picture

I can confirm this problem! The output as link is not working anymore. Also /home, and links like this are not working.

ayalon’s picture

Priority: Normal » Critical

Debugging shows that $alter['make_link'] is set to "FALSE" although the option in the view is selected.

File: views_handler_field.inc


    if (!empty($alter['make_link']) && !empty($alter['path'])) {
      if (!isset($tokens)) {
       $tokens = $this->get_render_tokens($alter);
      }
      $value = $this->render_as_link($alter, $value, $tokens);
    }

Did not find the reason for now. Trying to investigate further. Seems to me quite critical.

ayalon’s picture

Status: Postponed (maintainer needs more info) » Active
ayalon’s picture

StatusFileSize
new349 bytes

Ok I found the bug, but a maintainer is needed to confirm this:

Older version of views_handler_field_node.inc:

  function render_link($data, $values) {
    if (!empty($this->options['link_to_node']) && $data !== NULL && $data !== '') {
      $this->options['alter']['make_link'] = TRUE;
      $this->options['alter']['path'] = "node/" . $values->{$this->aliases['nid']};
      if (isset($this->aliases['language'])) {
        $languages = language_list();
        if (isset($languages[$values->{$this->aliases['language']}])) {
          $this->options['alter']['language'] = $languages[$values->{$this->aliases['language']}];
        }
        else {
          unset($this->options['alter']['language']);
        }
      }
    }
    return $data;
  }

Current dev version:

  function render_link($data, $values) {
    if (!empty($this->options['link_to_node']) && $data !== NULL && $data !== '') {
      $this->options['alter']['make_link'] = TRUE;
      $this->options['alter']['path'] = "node/" . $values->{$this->aliases['nid']};
      if (isset($this->aliases['language'])) {
        $languages = language_list();
        if (isset($languages[$values->{$this->aliases['language']}])) {
          $this->options['alter']['language'] = $languages[$values->{$this->aliases['language']}];
        }
        else {
          unset($this->options['alter']['language']);
        }
      }
    }
    else {
      $this->options['alter']['make_link'] = FALSE;
    }
    return $data;
  }

The else statement kills ALL link overrides because it sets $this->options['alter']['make_link'] = FALSE if its not a node link.

This codeline has to be reverted soon because a lot of views are affected.

dawehner’s picture

Status: Active » Reviewed & tested by the community

Let's revert the patch, find the old issue and find a working example

ayalon’s picture

Can someone have a look at this? I think it's critical. And easy to reproduce.

hernani’s picture

I can confirm that the patch submitted by ayalon on #5 solved the problem.

Thanks!

mattyoung’s picture

I'm using 6.x-2.11 and have the same problem. It used to work I think two versions ago.

now the link is like this:

http://wcegymnastics.com/node/nid

liquidcms’s picture

i think output field as link does work in 6.x-2.11 but it is broken in 6.x-2.x-dev.

anyone know if fix will get committed on 2.x branch as well (as would really be nice to get to use the clone a display feature that is in 2.x-dev)

liquidcms’s picture

applied patch above to 2.x-dev and fixes there as well.

ea777’s picture

Patch works for me. I'm running the latest dev version of views 3 (latest as of this today's date).

TS79’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.91 KB

Hi,

i attached a patch, which will solve the current problems of this issue and the/my problem from
#762484: faulty caching of link to node (views_handler_field_node), which existed only in case of link-to-node-option is selected for th field.

All current problems of this issze (which have been caused by my last patch, see #5 above) occure in situations, where the link-to-node-option is NOT selected. Isn't it??

So I propose only to set $this->options['alter']['make_link'] to FALSE, if link-to-node-option is checked AND there is no node-data returned from DB for this field (since the handler is used for a field of a left-joined-node-table without any match).

Description of Link-tonode-option ist "This will override any other link you have set.". So each developer should be aware of this.

I think both problems are solved with this patch.

dawehner’s picture

Assigned: dawehner » dagmar

Code looks fine, but i can't reproduce the bug so i can't test the patch.

TS79’s picture

okay, I try to explain a test case: Imagine you have 2 node types: story nodes and user nodes.

You create a view, which lists all of your nodes (unfiltered) in base table.
You show nid, the primary index of them, and type.
Now you want to have a third column, which shows a hard coded string "This is linked for a story node", which is linked to the story node in case it is a story node.

To achieve this, you use a left join of the reduced node table to the full node table:

SELECT n_base.nid, n_base.type, n_story.nid 
FROM (
  {node} n_base 
  LEFT JOIN
  (SELECT * FROM {node} WHERE type = 'story' ) n_story
  ON n_base.nid = n_story.nid
)

Returned data-result might be:


n_base.nid n_base.type n_story.nid
1 user NULL
2 story 2
3 story 3
4 user NULL
5 story 5

In views GUI you enable "link-to-node" for the n_story.nid field and overwrite the content with the hard coded string.

If everything works fine, you get the following view:


n_base.nid n_base.type n_story.nid
1 user This is linked for a story node
2 story This is linked for a story node
3 story This is linked for a story node
4 user This is linked for a story node
5 story This is linked for a story node

With the caching bug in place you get:


n_base.nid n_base.type n_story.nid
1 user This is linked for a story node
2 story This is linked for a story node
3 story This is linked for a story node
4 user This is linked for a story node
5 story This is linked for a story node
sreher’s picture

Thanks for the patch, work's for me.

mandreato’s picture

The patch #13 works for me too.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed to all branches.

Status: Fixed » Closed (fixed)

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

mattyoung’s picture

Title: Upgrading to the latest dev version breaks Output this field as a Link functionality » "Link this field to its node" incorrectly output path "node/nid"
Version: 6.x-3.x-dev » 6.x-2.12

I still have this problem after update to "2.12". The path I got is "node/nid". The string "nid" should be the node id value but it's just the literal string "nid".

I fixed the problem by adding the nid field, exclude it from display, use "Output this field as a link" instead and use "node/[nid]" as Link path pattern.

mattyoung’s picture

Status: Closed (fixed) » Active

Forgot to change status

merlinofchaos’s picture

Status: Active » Closed (won't fix)

I'm sorry, why did you make this active again? The committed patch is not in 2.12.

mattyoung’s picture

Sorry about this. I did looked at the code in render_link() and saw the code is like in the patch in #5, the else clause is gone. I thought that was the fix.

So the bug is still in 2.12?