sudeepg's blog

Performance Improvements in Drupal

The posting I made on drupal.org (http://drupal.org/node/346838):

Usage of complex CCKs does come at a performance cost, since, the tables are not optimized.

I have worked on Drupal performance and could get quite exceptional results with few of the techniques for some of the clients. Here are couple of things, that would make your Drupal site run quite fast:

How to debug in Drupal using drupal_set_message and come to the exact line that is causing the error?

Put the following code snippet in includes/bootstrap.inc in the drupal_set_message function.. .

<code>
 if ($type == 'error') {
    $message .= '<pre>'. print_r(debug_backtrace(), 1) .'</pre>';
  }
</code>

How to override node-xxx-edit.tpl.php in drupal 6

Could not find a proper solution yet. But, the temporary one goes here:


function custom_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
switch ($op) {
case 'load':
break;
case 'prepare':
if ( arg(2) == 'edit' ) {
$form = theme('article_edit', $node);
}
break;
}
}

 In template.php 
function theme_article_edit($form) {
return _phptemplate_callback('article_edit', array('user' => $user, 'form' => $form));
}

How to disable resizable textarea in Drupal?

Putting following code in template.php does that.

function phptemplate_textarea($element)
{
$element['#resizable'] = false ;
return theme_textarea($element) ;
}

How to Find Role of a user in Drupal

Following snippet finds if $user has the role ($role which is a string name of the role) or not:

if (is_array($user->roles) && in_array($role, array_values($user->roles))) {
return TRUE;
}

Remove Tabs from Drupal Site

Use the following function in '_phptemplate_variables' function in template.php. In the following code snippet, if I want to remove the "Edit" tab:


<?php
function _phptemplate_variables($hook, $vars = array()) {

if($hook == 'page') {
yourthemename_removetab('Edit', $vars);
// add additional lines here to remove other tabs
}

return $vars;
}

function yourthemename_removetab($label, &$vars) {
$tabs = explode("\n", $vars['tabs']);
$vars['tabs'] = '';

foreach($tabs as $tab) {
if(strpos($tab, '>' . $label . '<') === FALSE) {

Drupal: How to show Drupal messages in a Nice Lightbox!!!

1. Install lightbox2 on drupal

2.

By placing the code below in your theme's page.tpl.php file, it's possible to have Drupal messages appear as modal popups. Just add the following code:

<pre>

Drupal: How to Theme Menu

Following Code helps do that:

 

Another Drupal Performance enhancing Tool: SmartOptimizer

This one is easy to use tool to increase Drupal performance wonderfully and easily:

http://farhadi.ir/works/smartoptimizer

Above all, easy to install. Not more than 2-5 mins of task.

 

Improving Drupal's page loading performance

Following article is taken from here. Sorry, but couldn't help it..it is too good and I feared it would be lost :) 

Introduction

Google dominates the search engine market for a large part thanks to its spartan, no-bells-nor-whistles interfaces. But also thanks to its incredible speed (which is partially thanks to that spartan interface, of course).

Syndicate content