Skip to main content

PHP Tuning

Submitted by amitsedai on
For development site Change the php.ini file setting for apache: display_errors=On so that PHP errors can be known and change the setting error_report = E_ALL && ~E_NOTICE (Report all errors except notice type)

Apache Tuning

Submitted by amitsedai on
Enable Mod Expires Drupal states via .htaccess that if mod_expires is on, it caches all files for 2 weeks. This means that the browser would cache static content. Set KeepAlive On For Apache to wait until all the elements of a page requests are provided. MaxKeepAliveRequests -> How many download requests per page.. [Check with Firebug] KeepAliveTimeOut 15 --> How many seconds required for the page to load completely in the browser. 4 sec is a good threshold.

Theming CCK Fields

Submitted by sunildhimal on
There may be some situations wherein one would like to dispaly each CCK field in particular way.For example by default you have a lot of free space available in the right hand side of the node.One can theme CCK Fields so that it appears in free space. How to do this?

MySQL Tuning Best Practices

Submitted by amitsedai on
Based on video from lullabot, the following settings in my.cnf file in mysql for drupal performance and handling: Before beginning to start using MySQL it is recommended to run the script provided by MySQL to provide some security features. The link is: /usr/bin/mysql_secure_installation . The location can vary. It basically requests for root password, disabling remote root login, remove anonymous users and other security setting. Character Set: utf8. Drupal mostly expects the default character set to be utf8. default_character_set=utf8

Display different home page based on User Roles

Submitted by amitsedai on
Use Panels! Create layout as you like and set the panel as the home page of the site in the Site Information section. Add content in the panels with view permissions for specific user role. This would ensure that a user would be able to view specific content based on their role. Take care to ensure that a user does not have 2 roles :)

How to get the total number of nodes displayed by the view

Submitted by amitsedai on
There are times where we would want to view the total number of rows or data rows displayed in a view. The best way to do is to add a PHP snippet in the header section of a view. Fortunately, drupal views allow for adding code snippet into header and footer of a view. However, this code snippet will work only if pager is enabled in the view. The code snippet: <?php $view = views_get_current_view(); print "

Total Blood Banks: ".$view->total_rows."

"; ?> In-case, you would want to get data from a particular view, you can provide the snippet:

Update Comment Status of a Node

Submitted by amitsedai on
Just recently I had the issue where a list of nodes imported via user import as a content profile had comment status disabled. There were thousand of nodes to update, hence the best way was to use VBO. However, there was no option provided for comment status update, hence the alternative was to execute "Arbitrary PHP Code". The following snippet below can be used for updating node status for nodes selected in VBO: <?php $object->comment = COMMENT_NODE_READ_WRITE; node_save($object); ?> Happy Drupaling! -- External Links: http://drupal.org/node/673828

Add Tab - A Simple Drupal Module

Submitted by amitsedai on
addtab is a simple Drupal Module that adds a tab that provides links for adding same content type, ie whenever a content is viewed a tab would appear that would link to creating similar content. The Create tab that you can see in this page being displayed is basically due to this module. A drupal module consists primarily of two files .info and .module file. addtab.info: ; $Id$ addtab.info,v 1.0 2011/02/20 01:26:00 amitsedai Exp $ name = addtab description = Creates a new tab in a node view for adding same content type core = 6.x

Apache URL Redirection on VPS

Submitted by amitsedai on
I faced an issue with redirecting a particular URL to another URL at the Apache settings. You can write an index.php(php based solution) file for redirecting the header to the required URL. However, this didnt seem to me like an apt solution hence I looked for a solution at the Apache Config itself. Considering you have a VPS where you have configured the virtual host as follows: ServerName pr.example.com
ServerAlias pr.example.com
DocumentRoot /sites/www/pr.example.com/public_html/
ErrorLog /sites/www/pr.example.com/logs/error.log