国外设计欣赏网站 - DOOOOR.com

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,微信登陆

搜索

[Drupal教程] Drupal的组成部分 6.搜索系统

[复制链接]
发表于 11-29-2011 07:35 | 显示全部楼层 |阅读模式

he Drupal search interface manages a global search mechanism.

Modules may plug into this system to provide searches of different types of data. Most of the system is handled by search.module, so this must be enabled for all of the search features to work.

There are three ways to interact with the search system:

  • Specifically for searching nodes, you can implement nodeapi('update_index') and nodeapi('search_result'). However, note that the search system already indexes all visible output of a node, i.e. everything displayed normally by hook_view() and hook_nodeapi('view'). This is usually sufficient. You should only use this mechanism if you want additional, non-visible data to be indexed.
  • Implement hook_search(). This will create a search tab for your module on the /search page with a simple keyword search form. You may optionally implement hook_search_item() to customize the display of your results.
  • Implement hook_update_index(). This allows your module to use Drupal's HTML indexing mechanism for searching full text efficiently.

If your module needs to provide a more complicated search form, then you need to implement it yourself without hook_search(). In that case, you should define it as a local task (tab) under the /search page (e.g. /search/mymodule) so that users can easily find it.

函数

名称sort icon位置描述
do_searchmodules/search/search.moduleDo a query on the full-text search index for a word or words.
hook_searchmodules/search/search.api.phpDefine a custom search routine.
hook_update_indexmodules/search/search.api.phpUpdate Drupal's full-text index for this module.
search_boxmodules/search/search.moduleForm builder; Output a search form for the search block and the theme's search box. See alsosearch_box_form_submit()
search_box_form_submitmodules/search/search.moduleProcess a block search form submission.
search_datamodules/search/search.modulePerform a standard search on the given keys, and return the formatted results.
search_excerptmodules/search/search.moduleReturns snippets from a piece of text, with certain keywords highlighted. Used for formatting search results.
search_formmodules/search/search.moduleRender a search form.
search_indexmodules/search/search.moduleUpdate the full-text search index for a particular item.
template_preprocess_search_block_formmodules/search/search.moduleProcess variables for search-block-form.tpl.php.
template_preprocess_search_theme_formmodules/search/search.moduleProcess variables for search-theme-form.tpl.php.

|2011-2026-版权声明|平台(网站)公约|DOOOOR 设计网 ( 吉ICP备2022003869号 )

GMT+8, 3-15-2025 10:37 , Processed in 0.277591 second(s), 43 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表