How to derive HTML from a drupal module

this may be basic, but I just started using Drupal (6 battles).

I create a module and get a callback that some html should return. I could just do something like this:

function myModule_myFunction(){
    $r = '';
    $r .= '<h1>'.$variable.'</h1>';
    return $r;
} 

But I would rather separate the logic and presentation and put this in a separate file or something else. HTML in lines is ugly!

What is the drupal way to do this? No need to use the system as far as I know.

+5
source share
2 answers

a theme system is a drupal way to do this.

, , , , , , .

, ...

  • hook_theme(). , - yourmodule_something.

  • ( ), theme_, - function theme_yourmodule_something().

  • , Drupal .

  • theme(): theme('yourmodule_something', $argument1, $argument2):

.

+7

hook_theme .

, , theme_my_content my-content.tpl.php , :

theme('my_content', $param1, $param2);

+2

All Articles