Monday, January 18, 2010

Remove N/A option for radio buttons and select boxes in Drupal using CCK

Whenever you create a custom form fields with CCK In drupal, it is irritating us by displaying N/A for radio buttons and Selectboxes. You can remove this only through a code. goto modules/cck/modules/optionwidgets.module and find the function named optionwidgets_options() and comment the below code

if (!$field['required']) {
if ((in_array($field['widget']['type'], array('optionwidgets_buttons', 'nodereference_buttons', 'userreference_buttons')) && !$field['multiple'])
|| (in_array($field['widget']['type'], array('optionwidgets_select', 'nodereference_select', 'userreference_select')))) {
$options = array('' => theme('optionwidgets_none', $field)) + $options;

Now the N/A option is not displayed for radio buttons and select boxes.

Allow users to select Roles while Registration in Drupal

If you want to provide an option for the user to select roles in the registration form, use the module called user selectable roles. The module source url is
After install it in your application, you should goto administer->user mangement-> user_select_roles
There you can set which roles are displayed in the registration form and other options to select multiple roles selection or single etc.

Restrict accessing your site for some users based on their IP Address

In .htaccess add below lines

Order allow, deny
Deny from
Deny from
Allow from all

It is allowed accessing for all except fom IPs,,,

OR if you want to access your site from your IP only add below lines in .htaccess file

Order deny, allow
Deny from all
Allow from

This will be usefull for your site administrators.
If you set this for site admin, then the administrator can access admin area from the mentioned IP only.

Run PHP Code in HTML files

If you want to run PHP Code in your static HTML pages, you need to create .htaccess file (if it is not already exists) in the directory of where all your html files exists and add the below lines of code

For web servers using PHP as apache module:

AddType application/x-httpd-php .html .htm

For web servers running PHP as CGI:

AddHandler application/x-httpd-php .html .htm

If your requirement is only for one page then use below code

AddType application/x-httpd-php .html