Question

The HTML structure is the following one:

   <div id="contentp">
     <p>.........</p>
     <p>.........</p>
     <div id="rate-node-18-1-1" class="rate-widget rate-widget-1 clear-block rate-processed">...</div>
   </div><!--contentp  end ----!>

The part between <div id="contentp"> and </div> <!--contentp end ----!> is generated in node.tpl.php by the following snippet:

  <div id="contentp">
      <?php print $content; ?>
  </div>

The <div id="rate-node-18-1-1"> part is generated by the rate module.

I want to put the <div id="rate-node-18-1-1">...</div> part outside of the </div> <!--contentp end ----!>.

How I should do it?

Was it helpful?

Solution

Since Fivestar actually appends its markup to the bottom of the node's content (instead of using Links, for example), its a bit more tricky.

Ideally you would create a seperate node template for your content type, ie: node-story.tpl.php or something like that (depends on your theme).

Once you have a node template you can safely edit, do the following at the top:

<?php
$my_node_content = $node->content['body']['#value'];
$my_fivestar_widget = $node->content['fivestar_widget']['#value'];
?>

Then, instead of <?php print $content; ?>, do: <?php print $my_node_content; ?>

This way, only your node's actual body content will be printed out.

Then, wherever you want, just print out the fivestar widget code!

Here's what it would look like using your markup:

<div id="contentp">
  <?php print $my_node_content; ?>
</div><!--contentp  end ----!>

<div id="my_fivestar_container">
  <?php print $my_fivestar_widget; ?>
</div><!--my_fivestar_container end ----!>
Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top