Drupal

Customizing Search Block Form

In Drupal we can customize everything, even the search forms. This example show you how to make a custom search block. First you have to make a file named "search-block-form.tpl.php" with this content:

<div class="container-inline">
  <?php print $search_form; ?>
</div>

even if it isn't different from the one in the core distribution; otherwise the preprocess function isn't executed.

After that you must to open the template.php and use the mechanism of preprocess function to modify template variables before they are passed into the template files.
 

Place blocks and menus anywhere on the site

When you make a theme sometimes need to place a block directly into the theme instead of using the blocks section. For example, you need to insert the block in the page.tpl.php file what have to do is:

Print comments block:

<?php
$block = module_invoke('comment', 'block', 'view', 1);
print $block['subject'];
print $block['content'];
?>

Print locale block:

<?php
$block = module_invoke('locale', 'block', 'view', 0);
print $block['subject'];
print $block['content'];
?>

Print search block:

<?php

URL with trailing slash

Some people prefer use trailing slash for urls for example http://example.com/something/ instead of http://example.com/something, actually, according to RFC 3986 it does make a difference. Any two URLs are not a character-by-character match (ignoring URL encoding which does not apply in this case) are considered to indicate different resources.

Syndicate content