In the comment.tpl.php there is

    print render($content);

and this converts to this html

<span rel="sioc:reply_of" resource="/drupal/?q=node/5" class="rdf-meta" data-thmr="thmr_44">
<div class="field field-name-comment-body field-type-text-long field-label-hidden" data-thmr="thmr_49">
 <div class="field-items">
  <div class="field-item even" property="content:encoded">
   <p>THE COMMENT</p>

What can i do if only want text "THE COMMENT" printed and not all this html? I know $content is an array but can't find a way to dig into it's elements.

  • Hi, welcome to DA! "I know $content is an array but can't find a way to dig into it's elements." This makes it a basic PHP/programming question, and has nothing to do with Drupal itself. I'd say that makes it off-topic, and you should consult an intro to php. :)
    – Letharion
    Feb 8, 2013 at 14:54
  • you are right about this.I am a total newb in php.Anyway the dsm($content) helped a lot Feb 8, 2013 at 15:14

1 Answer 1


Install devel and try dpm($content);

This will give you an easy way to browse that array.

  • 1
    A note from the devel module: dsm() is a legacy function that was poorly named; use dpm() instead, since the 'p' maps to 'print_r'. stackoverflow.com/a/4054396/784877
    – AKS
    Feb 8, 2013 at 15:48

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.