Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To do the job, you must follow Drupal's best practices, supposing you are using D6, so you can insert some variables to your template like this :</p> <pre><code>// You menu path is good $items['mypath/mypage'] = array( 'title' =&gt; 'My Page!', 'page callback' =&gt; 'my_module_mypage', 'page arguments' =&gt; array(1,2), 'access callback' =&gt; true, 'type' =&gt; MENU_CALLBACK, ); </code></pre> <p>Second thing, we define the theme hook for our page</p> <pre><code>// We define here a new theme file for your your page // Your theme file must be located in your module's folder // you can use a subfolder to group all your module's theme files // E.g : themes/my-module-theme.tpl.php // Note that in theme files, we change _ by - function my_module_theme() { return array( 'my_module_theme' =&gt; array( // Keep that name in your mind 'template' =&gt; 'my_module_theme', 'arguments' =&gt; array( 'my_var' =&gt; NULL, 'my_var2' =&gt; NULL, ), ) ); } </code></pre> <p>Now we can create a file "my-module-theme.tpl.php" in the root folder of our module, and paste something like "foo AND bar!" Back to our my_module.module, the callback must be something like :</p> <pre><code>function my_module_mypage($x, $y) { // $x and $y are optionnal, so this is the first manner // to inject variables into your theme's file $output = theme("my_module_theme", $x, $y); return $output; } </code></pre> <p>Also you can use preprocess hook to insert variables</p> <pre><code>// The hook must be named like this : template_preprocess_NAME_OF_THEME_FILE // where NAME_OF_THEME_FILE is the name that you kept in your mind ;) function template_preprocess_my_module_theme(&amp;$variables) { // Do some job $var1 = 'Foobar'; // So in "my-module-theme.tpl.php", $my_var1 will print Foobar $variables['my_var1'] = $var1; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload