我目前正在打印搜索内容:
$block = module_invoke('search', 'block_view', 'search');
print render($block);
Wich生成:
<form action="/sescam/" method="post" id="search-block-form" accept-charset="UTF-8">
<div>
<div class="container-inline">
<h2 class="element-invisible">Search form</h2>
<div class="form-item form-type-textfield form-item-search-block-form">
<label class="element-invisible" for="edit-search-block-form--2">Search</label>
<input title="Enter the terms you wish to search for." type="text" id="edit-search-block-form--2" name="search_block_form" value="" size="15" maxlength="128" class="form-text" />
</div>
<div class="form-actions form-wrapper" id="edit-actions">
<input type="submit" id="edit-submit" name="op" value="Search" class="form-submit" />
</div>
<input type="hidden" name="form_build_id" value="form-NhLKDp33kDMoJjHqw6gDFJw_A_Kp7Dhvrt_w0V-jk6U" />
<input type="hidden" name="form_token" value="e9aNbw3gz2mWvZUSdjl54aXTlesQsNkn7cGSXVMpoWI" />
<input type="hidden" name="form_id" value="search_block_form" />
</div>
</div>
</form>
问题是我想自定义一下这个html输出,
我该怎么办?
- 编辑 -
我尝试将此添加到我的template.php
function my_theme_form_search_form_alter (& $form, & $form_state)
{
print_r($form);
print_r($form_state);
}
问题是那些print_r
不会输出任何东西,
Anhy想法?
谢谢!
答案 0 :(得分:0)
/**
* Implements template_preprocess_search_blok_form.
*/
function YOUR_THEME_preprocess_search_block_form(&$variables) {
var_dump($variables,'vars');
// do your thing
}
或
/**
* Implements hook_form_alter.
*/
function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'search_block_form') {
dpm($form,'form'); // install devel module for dpm() function
// do your thing
}
}