I have a VIEW which pulls on the content field of a type. I specified I want the rewrite rules to trim to 25 characters with an ellipsis.

Unfortunately I also override the template (views-view-unformatted--XXX.tpl.php) and when I echo out the structure of the entire node and entity in template.php I see nothing of a modified field -- only the full data.

How do I adhere to the requirements of the field set in the VIEW?

1 Answer 1


I am not exactly sure of what your are looking for. When I need to change the output of a field I usually change the $view->result for the field in hook_views_post_execute.

  • I have a view in which I specify the content should be of 128 characters in length and "..." added. However when I pull on the $view->result data all I see are the full content not the truncated version I set in views. May 22, 2014 at 17:57
  • I have noticed that views does not always work as I imagine it when I am setting them up. You should be able to modify $view->result for each item and use strlen, substr and concatenation to achieve the desired effect through code. Maybe something like foreach ($view->result as $result) {if strlen($result > 128{$result = substr($result, 0, 128) . '...';}} It is rough code and syntax may be off especially the substr but it should give you a good idea.
    – sareed
    May 22, 2014 at 18:05
  • I don't want to achieve the result through code tho...I have already (truncate_utf8) but I want the resulting data returned by views to give me the proper field data so a change in the UI doesn't require a change in the code at some later point. May 22, 2014 at 18:08
  • Ah gotcha. I have similar issues and just go to code. Sorry I could not be more help. Maybe if you can pull the settings in from the view to define the code changes it would work the way you want it to.
    – sareed
    May 22, 2014 at 18:11
  • I dumped the whole damn $view object and the modified/truncated text is in there but its nested so deeply...I was hoping there was an API to help I wasn't aware of... May 22, 2014 at 18:13

Your Answer

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

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