Chinaunix首页 | 论坛 | 博客
  • 博客访问: 334807
  • 博文数量: 89
  • 博客积分: 5152
  • 博客等级: 大校
  • 技术积分: 1155
  • 用 户 组: 普通用户
  • 注册时间: 2006-02-25 15:12
文章分类

全部博文(89)

文章存档

2012年(1)

2011年(5)

2010年(14)

2009年(69)

我的朋友

分类: 系统运维

2009-06-26 11:20:24

修正前:


修正后




Step 1. Create search form using Drupal Form API.

Step 2. Register our theme in Drupal theme registry using hook_theme().

Step 3. Create search-form.tpl.php file to theme this search form.


function search_form() {
    $form['str'] = array(
    '#type' => 'textfield',
    '#size' => '32',
    );
 
    $form['category'] = array(
    '#name' => t('category'),
    '#type' => 'select',
    '#options' => array('0' => t('All'), '1' => t('Bars'), '2' => t('Restaurants')),
    );
 
    $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Search'),
    );
 
    return $form;
}




























function search_theme() {
  global $theme;
 
  return array(
    'search_form' => array(
      'arguments' => array('form' => NULL, 'theme' => $theme),
      'template' => 'search-form',
    ),
  );
}

<table cellspacing="0">
    <tr>
        <td class="container-inline"><strong><?php print t('Search');?></strong> <?php print drupal_render($form['str']); ?></td>
        <td class="container-inline"><strong><?php print t('Category');?></strong> <?php print drupal_render($form['category']); ?></td>
        <td><?php print drupal_render($form['submit']); ?></td>
    </tr>
</table>
<?php
print drupal_render($form);
?>

阅读(1166) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~