I am turning to Drupal from Wordpress to open my development possiblity more. One question I have is about generating page content with a module. I read and completed the tutorial here: http://drupal.org/node/206762 but one thing that bothered me is that, in order to display information on the page, you have to return the variable that holds your html. I am used to the situation (and prefer it) in Wordpress and in Joomla where you can just echo out your display items rather than gathering them in a variable. This allows you to take advantage of your IDE specific coloring and autocomplete. For example, in Drupal, I would do this (very rough examples):

<?php
$content = "<div> Hi, everyone </div>";
$content .= "<div> how are you </div>";
return $content;
?>

But in WP or Joomla, i would be able to use raw html

<?php
?>
<div>
     Hi, everyone 
</div>
<div>
     <?php echo $second_line; ?>
</div>

<?php

If I try to echo straight from the module function in Drupal, it ends up above the page. So, finally my question, is there ANY way to generate page content in Drupal, similar to the second example?

Comments

jaypan’s picture

Not exactly. You can't just output data like that, but you can pass data off to a template file that will do something similar. Here's an example I wrote the other day:

http://drupal.org/node/735370#comment-2731904

Contact me to contract me for D7 -> D10/11 migrations.