1

In a content node, I wanted to wrap a div around some results. For example: I have this inputs:

Image Title Body Address Email Name

And I wanted to have divs like this: DIV Image Title /DIV DIV body Adress Email /DIV DIV Name /DIV

Is this in any way possible?

  • Have you thought about creating a custom node.tpl.php for the content type (drupal.org/node/17565) then pulling the field values wrapped with anything you want? – Daniel Rogers Jul 22 '14 at 22:24
  • I thought about. But how do I divide the results in different divs on php? – Ricardo Aquino Jul 22 '14 at 22:50
0

So, if you create a new .tpl.php for your content type, you can simply print the divs as html, and echo the vars as php.

example:

<div class="MyClass">
<?php print $title; ?>
</div>
<div class="MyOtherClass">
<?php echo render($content['some_field']); ?>
</div>

See https://stackoverflow.com/questions/8074485/drupal-7-how-to-render-custom-field for a starting point on pulling specific custom fields, for separation, if needed.

be sure to have a copy of your original node.tpl.php in your theme folder as well, or your node--my-content-type.tpl.php wont work! Again, see https://www.drupal.org/node/17565.

| improve this answer | |
  • I could kiss you, Daniel! It worked! – Ricardo Aquino Jul 23 '14 at 4:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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