Category: Drupal

drupal clean URLs not working? with tilde sign

If your site is developed in Drupal and your URL looks like this:

If your site URL looks like this:

http://[domain name OR IP Address]/~[accountname]/anyFolder/


Then you need to set RewriteBase!in your .htaccess file that looks like below

RewriteBase /~xyzaccount/somefolder

Create template specific to node in drupal 6

If you want to have custom templates for your node. You can create templates specific to node ID as follows.

Add the below function in your template.php if its not exists.

function yourcurrentthemename_preprocess_node(&$vars, $hook) {
$node = $vars[‘node’];
$vars[‘template_file’] = ‘node-‘. $node->nid;

If the function already exists then add the two lines at the beginning of the function.

Then clear the cache.

So if you want to have a custom template for node id 3 (say for example) then create a template with name node-3.tpl.php in your theme directory.

Now you can customise your template as you need.

Keep Rocking…..Enjoy 🙂

How to get the allowed option list in drupal theme template or view file

If you want to get the option list of the content type that you have created , then you can get the list as follows:

$content_field = content_fields(‘whatever_the_field_name_is’);
$allowed_values = content_allowed_values($content_field);

So the $allowed_values will give you the array of the option list with the key value association.

Note: The “whatever_the_field_name_is” is the field name that you had specified while adding the field, you can get the field name from your content type .

How to add select option in drupal while creating content type

Whenever you create any content type in drupal ( version 6 and above) and you required a filed of type select list, then you can provide the allowed values of the select option in two ways

CASE 1 :

option 1
option 2
option 3

CASE 2 :

1|option 1
2|option 2
3|option 3

Each new option has to be entered on a new line
So enternally the select list generated would be as follows
In case 1 :

<option value=”option 1″>option 1</option>
<option value=”option 2″>option 2</option>
<option value=”option 3″>option 3</option>

In case 2 :

<option value=”1″>option 1</option>
<option value=”2″>option 2</option>
<option value=”3″>option 3</option>