Clear Drupal 7 cache by Mysql queries

Paste the following queries in your phpmyadmin where your drupal 7 database resides.

  • truncate table <your table prefix>_cache;
  • truncate table <your table prefix>_cache_block;
  • truncate table <your table prefix>_cache_bootstrap;
  • truncate table <your table prefix>_cache_field;
  • truncate table <your table prefix>_cache_filter;
  • truncate table <your table prefix>_cache_form;
  • truncate table <your table prefix>_cache_image;
  • truncate table <your table prefix>_cache_menu;
  • truncate table <your table prefix>_cache_page;
  • truncate table <your table prefix>_cache_path;
  • truncate table <your table prefix>_cache_token;
  • truncate table <your table prefix>_cache_update;

Remember to replace "<your table prefix>" with your Drupal table prefix.

All cache will be cleared.

Bonfire: Removing index.php from URL

The document given in for removing "index.php" from the URL in codeigniter framework needs some correction in case of Bonfire framework.

So follow these steps for removing the "index.php" in Bonfire.

Create an .htaccess file in the root of Bonfire installation and add the following code it it.

# Apache for "Don't look at me."
Options -Indexes

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Save and open any link without index.php. However you will also have to change the links in your application so that they are without "index.php".

Drupal7 how to override page.tpl for specific content type

Sometimes there is a need to override page.tpl.php for specific content type. Like for articles it will be page--article.tpl.php etc.

For this, place this code in your theme's template.php file

function themeName_preprocess_page(&$vars, $hook) {
  if (isset($vars['node'])) {
    // If the node type is "product" the template suggestion will be "page--product.tpl.php".
    $vars['theme_hook_suggestions'][] = 'page__'. $vars['node']->type;

Working with uploadify and multiple fields in a page

Uploadify is a jQuery plugin by which you can create the file upload functionality. You can know more about the plugin or download it in this page The problem I faced with one of my projects is using uplodify in multiple fields in a single page.

Here is the code which did the trick.

$('.myupload').each(function() {
    var $myupload = $(this);

        'uploader': '/images/uploader.swf',
        'cancelImg': '/images/cancel.png',
        'script': 'ajax_call.php',
        'auto'      : true,
        'removeCompleted' : false,
        'wmode': "transparent",
        'hideButton'  : false,
        'multi': false,
        'displayData': 'percentage',
        'scriptData'  : ....for any script data you want to send.... ,
        'onSelect'    : ....write here the function which you want to execute when the field is selected....,
        'onComplete'  : function(event, ID, fileObj, response, data) {
           ..... put here the code you want to execute when the file is completely uploaded..... 

Here I placed the class "myupload" in all the fields of the page where I wanted the uploadify to work.

Using newer versions of jQuery in Drupal frontend

Download a newer version of jQuery from the jQuery website ( Suppose you downloaded it in "misc" folder of your drupal installation and the file name be "jquery-1.11.0.min.js".

So put this code in your frontend themes "template.php" file.

function <your theme name>_js_alter(&$javascript) {
  // Swap out jQuery to use an updated version of the library.
  $javascript['misc/jquery.js']['data'] = 'misc/jquery-1.11.0.min.js';

Now flush the cache either from admin panel configuration >> performance OR by drush with command drush cc all

Drupal 7 upload image with CKEditor by using IMCE module

CKEditor is a powerful wysiwyg editor useful for changing contents in Drupal. But the main drawback is that it does not have any image uploading feature. This can however be solved by using the IMCE module of Drupal. Here are the steps for integrating IMCE with CKEditor.

Step 1. Download IMCE module from OR drush dl imce.

Step 2. Upload IMCE module in sites/all/modules folder and enable module from admin/modules (in Drupal 7) admin/build/modules (Drupal 6). OR drush en -y imce

Step 3. Now check configuration option Configuration->IMCE (/admin/config/media/imce), and also configure the permissions.

Step 4. Now configure CKEditor go to Configuration->CKEditor (admin/config/content/ckeditor). There is two Profiles by default in Drupal 7 now edit ‘Advanced’ profile.

Step 5. Select ‘FILE BROWSER SETTINGS’ select ‘IMCE’ from File browser type drop down list.

All done. You will now get a browse button for image uploading in CKEditor.

Drupal 7 using drush to install CKEditor

CKEditor is very helpful in editing the pages and contents in Drupal. The following commands will install this powerful editor in your drupal project with ease.

First download the module with this command.

drush dl ckeditor

Now enable the module.
drush en -y ckeditor

Now download the actual library.
drush ckeditor-download

Now flush your cache.
drush cc all

The above steps will install the editor. To configure it you can go to the CKEditor settings and input profiles.