I have a content type with a Long text and summary field. In the node view display, it is set to to show as Summary or trimmed.

I have a module that gets all the nodes of that content type.

How do I programmatically get the trimmed value of that field? Using var_dump(), I get the following output.

  array(1) {
    array(1) {
      array(5) {
        string(5763) "<p>Test user DescriptionTest</p>"
        string(0) ""
        string(9) "full_html"
        string(5764) "<p>Test user Description</p>"
        string(0) ""

1 Answer 1


The summary value will only be set if someone has actually filled out the summary textfield when editing the node. You'll need to do the trimming yourself in code. Drupal has functions such as https://api.drupal.org/api/drupal/modules%21field%21modules%21text%21text.module/function/text_summary/7.x or views has https://api.drupal.org/api/views/views.module/function/views_trim_text/7.x-3.x

So you'll need to do a check to see if the summary value exists, if it doesnt use the main text and trim it with the functions or something similar above

  • ah okay, so it doesn't actually fill the $node using the defs on the display - might make sense thanks
    – xotix
    Mar 2, 2018 at 10:32

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.