Drupal 6.x

How to add an Vocabulary in an install file

This is how you add an Vocabulary in an install file or in a module.

/**
* Install
*
**/
...
$vocab_count = db_query("SELECT COUNT(vid) AS vid_count FROM {vocabulary}
WHERE name = '%s'", 'A name');

$vocab_count = db_fetch_object($vocab_count);
$vocab_count = $vocab_count->vid_count;

if ($vocab_count == 0){
$vocab = array();

$vocab['name'] = 'A name';
$vocab['description'] = 'A description';
$vocab['help'] = 'Some help';
$vocab['multiple'] = 0;
$vocab['required'] = 1;
$vocab['module'] = 'zimplicit';
$vocab['no

Node path to path alias array

Convert Drupal node path, "node/123.." to path alias and store it in an array. Useful when you have conditions based on path alias in your module or template files.

<?php
 
//Get path alias from arg() function and back to array
 
$path = implode('/',arg());
 
$path_alias = drupal_get_path_alias($path);
 
$arg = explode('/', $path_alias);

 
$show_path = array("knowledgebase", "knowledge", "search", "convert", "extract", "password");
 
  if (
in_array($arg[0], $show_path)) {
    
//Do something...
 
}

?>

Customize specific blocks

In your themes block.tpl.php you can add a litle script that converts the title to a class to the wrapping div tag. First add the following in a php section:

<?php
$block_class_title
= 'block-'.strtolower(str_replace(" ", "-", $block->subject));
?>

It will convert "My Title" to "block-my-title".

Manipulate breadcrumbs

First have a look in your theme settings example.com/admin/build/themes/settings/my_theme.

In Breadcrumb settings you can decide to display breadcrumb and breadcrumb separator. Select if you want to show home page link in breadcrumb and append a separator to the end of the breadcrumb, useful when the breadcrumb is placed just before the title. Append the content title to the end of the breadcrumb
Useful when the breadcrumb is not placed just before the title.

/**
* Make breadcrumbs include the current page as an inactive crumb

Pages