It seems that the Global Custom Text field in a view delete part of my text.

I write this:

<div class="my-class" style="width:100px">Hello</div>

but get this:

<div class="my-class">Hello</div>

The text removed is this


I need to be able to include it.

The value of the 'width' is provided by a token ([field_width]), that's why I need to add it here. It is dynamic value.

Update: I just see that this is a security measure, then how can I make View accept this using a function?

  • try css please
    – niksmac
    Commented May 29, 2015 at 11:43
  • @NikhilM how?, it is dynamic value entered in the node field Width which is added with a token replacement.
    – chefnelone
    Commented May 29, 2015 at 11:56
  • I spent like 20 mins giving you a perfectly good detailed step by step answer, but I guess you were too lazy to try it. Now my answer is gone!
    – No Sssweat
    Commented May 29, 2015 at 15:56
  • drupal.org/node/853880#comment-5652114 Commented May 29, 2015 at 16:28

1 Answer 1


Here is a fun and a little naughty solution to this:

1.) Instead of style, set the token as value="[token]" - make sure your token is only a number, no alphabetic characters like px etc.

--- Value is set and DIV is spat out ---

<div class="my-div" value="100"></div>

2.) Use jQuery to get the value of value="" - define it and use it when the page loads:

var div_width = $('.my-div').val();

The width will now be appended to the div via inline-style using jQuery. Not optimal, not recommended but it should work.

More on adding custom jQuery to your Drupal installation: https://www.drupal.org/node/171213

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.