Description:
1. Add a views url field (any field that uses views_handler_field_url, e.g. Node: Link) and check the option "Display as link"
2. Add a "Global: Contextual Links" field, and assign the field from step 1 as a contextual link

Expected behavior:
the field from step 1 renders as a link inside the contextual links

Actual behavior:
the field from step 1 is html-encoded, and the link is ignored

Proposed solution:
set values in the options['alter'] array instead of returning a rendered link (similar to the way it works in views_handler_field_node_link)

Comments

aaronbauman’s picture

Status: Active » Needs review
StatusFileSize
new744 bytes
aaronbauman’s picture

StatusFileSize
new744 bytes

s/p0/p1/

Status: Needs review » Needs work

The last submitted patch, views_handler_field_url-1638074-1.patch, failed testing.

dawehner’s picture

+++ handlers/views_handler_field_url.inc	(working copy)
@@ -34,7 +34,10 @@
+      $this->options['alter']['make_link'] = TRUE;
+      $this->options['alter']['path'] = $value;
+      $text = !empty($this->options['text']) ? $this->options['text'] : $this->sanitize_value($value);

This looks fine, beside a little thing.
Shouldn't you better set html to TRUE as well?

aaronbauman’s picture

Status: Needs work » Needs review
StatusFileSize
new762 bytes

The code is pulled directly from views_handler_field_node_link.inc, which does not change 'html' to TRUE.
Either it's up to the user whether they're including HTML in their rewrite values, or it's up to Views to assume that 'make_link' implies 'html'.

aaand i uploaded the same file twice.
here's the new patch.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

This patch looks fine from my perspective.

dawehner’s picture

Status: Reviewed & tested by the community » Needs review
+++ views/handlers/views_handler_field_url.inc	(working copy)
@@ -34,7 +34,10 @@
+      $text = !empty($this->options['text']) ? $this->options['text'] : $this->sanitize_value($value);

Before the commit i'm wondering why $this->options['text'] is not sanitized but the actual value is? Both could be user input ...

aaronbauman’s picture

StatusFileSize
new739 bytes

Actually, i think neither value needs to be sanitized.
Does views decide later, based on other views options, whether the value should contain HTML?
I'm not 100% intimate with views' rendering pipeline.
views_handler_field_node_link.inc does not sanitize $this->options['text'] either, so I assumed it was unnecessary.

dawehner’s picture

Status: Needs review » Needs work

Well render_as_link sets html to TRUE, so you have to sanitize the value in the render method, see views_handler_field::render()

aaronbauman’s picture

Status: Needs work » Needs review
StatusFileSize
new792 bytes

ok, i understand now.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Looks perfect now!

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Perfect! Finally committed to 7.x-3.x and 8.x-3.x

Status: Fixed » Closed (fixed)

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