Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.8
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
18 Dec 2009 at 19:08 UTC
Updated:
5 Apr 2010 at 20:10 UTC
Replacement tokens do not work in link's target when you set checkbox "Output this field as a link" for a field.
I applied a patch to resolve this issue.
If this is not a bug, there should be a notice to users explaining that the replacement tokens do not apply to the Target field
| Comment | File | Size | Author |
|---|---|---|---|
| views_handler_field.inc_.patch | 547 bytes | dan.nsk |
Comments
Comment #1
merlinofchaos commentedSetting proper status
Is there a use case for that kind of data in the target field?
Comment #2
dawehnerSure. For example if you build a dynamic link to yourfancystuff_with_nodeid/[nid]
Comment #3
merlinofchaos commentedNo, link target is where you add things like target="_blank" to the link so you can have it come up in other windows.
Comment #4
merlinofchaos commentedUnless I'm totally misremembering, that is.
Comment #5
dan.nsk commentedHere is my usecase. I need to provide the content administrator with an ability
to manage a set of advertisment links (for example). One way to achive this is to create a
simple node type and use its body's text to compose a link. WYSIWYG editor
could be used.
But sometimes this way seems to be too complex. Administrator is too lazy and
doesn't want to deal with raw HTML or even visual editor.
So I create a node type with separate cck-fields for link's URL, text, target
and title and create a view to output the list of links. I add to my "Link text"
cck-field to the view and enable checkbox "Output this field as a link".
Then I fill all the link's properties with tokens. For example, I use [field_link_url_value]
for "Link path" and [field_link_target_value] for "Target".
That's why I need tokens to apply in link's target
Comment #6
_vid commentedMy use case is very similar to dan.nsk.
I have a custom content type for links with name, url, description and a target check box: 'open in a new window' {"off","on"}.
Then in my view I exclude and rewrite [field_link_target] as "_blank" and hide if blank.
Then I exclude url and body.
With the title I attempted to rewrite the output like this:
<a href="[field_link_url_value]" title="[body]"[field_link_target_value]>[title]</a>but both body and field_link_target_value were ignored while in a link. *(field_link_target_value was rewritten as ' target="_blank"' at that point.So I used output this field as a link and put [field_link_target_value] in for the target. But since check_plain is used it actually outputs target="[field_link_target_value]".
*edit - Oh, I just noticed the patch! The following is redundant
Here is the fix that worked for me:
That works great for me. If that seems logical I hope you'll consider including this change.
In the interim I'd like to override views_handler_field.inc but adding the modified version to my theme folder didn't work. I'll have to dig around and see if there's a better way to override views functions.
Keep up the great work!
Thanks.
Comment #7
crashtest_ commentedI can see that the case presented in comment 5 could be pretty useful in the right circumstances, such as his. I hadn't though to use it that way, but it does make sense.
Tested the patch, works fine. Now, we just need a "rel" field so we can add rel="lightbox" to it :)
Comment #8
merlinofchaos commentedCommitted to all branches. Thanks!