Hi, I am having a problem in connection with using a rewrite on a field that has [token]-like values in it causing unintended results in views output.
'field_video_upload_fid' => array(
'label' => 'Video',
'alter' => array(
'alter_text' => 1,
'text' => '<a href="[field_video_upload_fid]" rel="lightvideo[|width:400px;height:300px;][caption]">[title]</a>',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'label_type' => 'widget',
'format' => 'url_plain',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_video_upload_fid',
'table' => 'node_data_field_video_upload',
'field' => 'field_video_upload_fid',
'relationship' => 'none',
),
The text in the rel="..." argument is supposed to be specific to lightbox2 and it seems like views is parsing the [] brackets and having a hard time with it. Maybe you guys can help with a solution. Lightbox2 forum had me experimenting with filters to no avail #483798: rel attribute lightframe disappears if I fill in a width.
The processed results of this code comes into the browser as:
<a href="http://localhost/sites/default/files/video/Wildlife.wmv" rel="300px;][caption]">Media node</a>
You can see, the text in the rel= is very mangled
First, if this is just a poor way for lightbox to get its parameters considering it supports views and [] are a universal token parameter, is there an easy way I can escape the [ open bracket parsing? I tried a backslash... and tried single quotes. I also tried turning off lightbox, using zzz="..." as the parameter, changing lightbox to any text... it's like a magic sequence in the *[|width:400px;height:300px;]* sequence that's breaking the output from Views.
I am looking forward to your considered response!
-- glen
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | replacement-workaround-doc-4.patch | 1.55 KB | iamjon |
| #14 | replacement-workaround-doc-3.patch | 1.98 KB | iamjon |
| #13 | replacement-workaround-doc-contexted.patch | 2.09 KB | iamjon |
| #12 | replacement-workaround-doc.patch | 897 bytes | iamjon |
Comments
Comment #1
glen201 commentedBump?! Anyone know how to escape the [] in a rewrite field?
Comment #2
jascott commentedRe-write with brackets using HTML special chars
[(left square bracket) and](right square bracket):<a href="[field_photo_fid]" rel="shadowbox[[name]]">[name]</a>This works in the 'Rewrite the output of this field' option because it allows HTML. The 'Output this field as a link' option does not allow HTML.
Changed category to 'support request' and 'by design'.
Comment #3
ahb commentedThis actually has the same effect as it did with unescaped []
Comment #4
merlinofchaos commented'needs review' means it has a patch applied.
'critical' is reserved for crash bugs.
Comment #5
wgrunberg commentedI was able to successfully escape [ and ] in URL's by using URL safe encoding (hex).
[ = %5B
] = %5D
I am generating "Add Content" links with prepopulated content (http://drupal.org/project/prepopulate). It works great with my CCK fields!
Comment #6
merlinofchaos commentedOh! Good catch!
This workaround should be added to the documentation right there with the replacement tokens so everybody can find out about it.
Comment #7
Jerome F commentedThat is also a workaround to use a lightbox in an url rewrite.
http://drupal.org/node/738670
Comment #8
Jerome F commentedActually it isn't I tested it with no success, but nevermind for that use case there is the lightbox views trigger.
Comment #9
tallsimon commentedJust what I was looking for wgrunberg thanks!
Comment #10
3rdLOF commentedThis issue can be solve by doing a very simple patch to the lightvideo.js file as described here:
http://drupal.org/node/483798#comment-2263568
The problem are not the brackets but the colon separators.
Now, Jerome had the right idea with the ;ightbox trigger EXCEPT if you want to pass extra fields within the lightbox rel call.
In my case I have created a video recipe that uses a width and height fields in the submission form. I wanted to pass that info to the lightvideo rel via tokens, so using lightbox trigger would not work.
This small mod changes the ":" to a "=" and it takes of the problem.
Example:
<a href="[field_video_fid]" rel="lightvideo[|width=[field_video_width_value]px; height=[field_video_height_value]px;]">[field_video_thumbnail_fid]</a>Now if I can just automate the collection of the video dimensions upon upload I will be a happy man.
Comment #11
Jerome F commented@ kannary
Did you do this patch or did you directly hack the module file ?
Comment #12
iamjon commentedI've created a patch to document the work around in comment 5 http://drupal.org/node/567918#comment-2381656
Hope it helps
Comment #13
iamjon commentedI'm re-adding but this time with context...I hope.
Comment #14
iamjon commentedSo apparently patches and me aren't friends.
Here is my third attempt.
Comment #15
iamjon commentedone day people will point to this and say...and that's how he learned to patch
Comment #16
dawehnerAnd you will say look back and see a lot of patches from yourself.
Take care of youself, i did the same 1,5 years ago and then i got a bit involved.
Comment #17
merlinofchaos commentedCommitted to all branches.
Congrats on getting your first patch in!