Friday, February 21, 2014

Drupal 6 file_directory_path not exists in Drupal 7

Drupal 6 file_directory_path not exists in Drupal 7. Use variable_get('file_public_path', conf_path() . '/files'); instead of file_directory_path();

The following function is return file directory relative path:  drupal_realpath('public://')

Thursday, February 13, 2014

Image not imported in Drupal 7 migration from Druapl 6

In node_export drupal module having issue to import images/files in Drupal 7

Fixed:
In Drupal 7, we have to use file_create_url() instead of url() in node_export.module line no 1052 - Refer - https://drupal.org/node/1264256

Find table column in MySQL

The following query is used to show all columns in each table in a database

SELECT * FROM information_schema.columns
WHERE table_schema = 'db_name'
ORDER BY table_name,ordinal_position

Tuesday, February 4, 2014

Load content field default image in Drupal 7

Code to get and display the Content(CCK) field information and display default image

$field_name = 'field_name';
$field = field_read_instances(array('field_name' => $field_name));
$field_fid = $field[0]['settings']['default_image'];
$image = file_load($field_fid);
$path = file_create_url($image->uri);

Tuesday, December 31, 2013

Embed view block or page in code or block

We can embed a views page or block in code or block.

<?php print view_embed_view('view_name', 'block_page_name'); ?>