开发者

drupal: add search field to an article

开发者 https://www.devze.com 2022-12-20 17:58 出处:网络
how can I add the search field (searching for all content and tags in my webiste) to my article ? I\'ve already installed and activated the module, but I would like to add it to a single article inst

how can I add the search field (searching for all content and tags in my webiste) to my article ?

I've already installed and activated the module, but I would like to add it to a single article instead o开发者_Go百科f a block of my website

thanks


There are several ways of doing searching in Drupal, but I guess you refer to the search module that's in Drupal core. It's usually used as a block which makes it a bit tricky if you want to display it with the article content.

You can use the theme function to theme a block like this:

<?php print theme('block' $block); >?

Where $block is a block object with all the data needed. To use this in your case, you could make a custom template for the article, since you only want to display the search block on one article. You would also need to make a preprocess function for the article (preprocess_node) where you create the block object. You could also just create some logic in the preprocess function and make a generic node template where you only print the block when it's there.

It is possible to control when blocks are displayed, so you could just setup your search block to only be displayed on your chosen article. That is far less work, but you wont be able to display it with the article content.

0

精彩评论

暂无评论...
验证码 换一张
取 消