By number3 on
Hello,
I noticed that with the site serach module, you care allowed to echo, from the page.tpl.php, '$search_box' and it will echo a form with a submit button and a text box.
I was wondering how does that work in relation to the search modules' methods? In the search module there is a method called 'search_box($form_id = 'search_theme_form')' and the form items defined in this method are the items that are echoed when you echo '$search_box'.
So if I create a module with _box and create a form with items, can I echo the form to the page by using echo $_box in the page.tpl.php?
Can someone please elaborate on how this works?
Thanks,
Comments
The quick answer is no
Variables in PHPtemplate are set by the theming engine. In the case of $seach_box it is "special" in the the engine calls the approriate search module function to generate the form.
Normally for a module to produce a page with a form, the module defines a path (with the menu hook) that has a callback. The callback then is responsible for generating the form (using the form API).
PHPTemplate variables
This is how the variables are set in page.tpl.php
http://api.drupal.org/api/4.7/function/phptemplate_page
as you can see:
$search_boxis generated by:You can change the variables in page.tpl.php and other templates or add new ones by following these instructions:
http://drupal.org/node/16383
--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ