JAFFAR

Blog

view:  full / summary

drupal 6 sprintf equivalent drupal7

Posted by jaffar on March 19, 2014 at 12:45 AM Comments comments (0)

$query = db_select('block') ->condition('theme', $theme_key) ->condition('status', 1) ->fields('block');dpm((string) $query);dpm($query->arguments());

SCSS for Drupal

Posted by jaffar on October 14, 2013 at 1:20 PM Comments comments (0)

Enable PHP memcache in windows

Posted by jaffar on September 11, 2013 at 9:40 AM Comments comments (0)

Steps to enable PHP memcache in Windows

  1. Download files http://downloads.php.net/pierre/php_memcache-2.2.6-5.3-vc9-x86.zip
  2. Extract and place in D:\wamp\bin\php\php5.3.10\ext\php_memcache.dll
  3. add the code "extension=php_memcache.dll " in php.ini file
  4. Download memcache.exe in http://code.jellycan.com/files/memcached-1.2.6-win32-bin.zip
  5. extract and place in D:\wamp\bin\php\memcache.exe
  6. Open command prompt
  7. type "cd d:\wamp\bin\php"
  8. type "D:\wamp\bin\php\memcached.exe -d install"
  9. type "D:\wamp\bin\php\memcached.exe -d start"
  10. Restart apache
  11. Test your memcache working execute the below code

   <?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");

$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";

$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;

$memcache->set('key', $tmp_object, false, 10) or
die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)
<br/>\n";

$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";

var_dump($get_result);
?>



   Refer: http://www.leonardaustin.com/technical/how-to-install-memcached-on-xampp-on-windows-7


Export mysql query result to csv

Posted by jaffar on September 11, 2013 at 7:10 AM Comments comments (0)

Export mysql query result to csv

mysql -u <username> -h <hostname> <databasename> -p"<password>" -e  "SELECT title FROM node" -B > /home/tmp/excel1.csv                    

 

Print data to PHP Error Log

 For Windows

ini_set("log_errors", 1);

ini_set("error_log", "D:/wamp/logs/php-error.log");

error_log( "Hello, errors!" );

 

For Linux

ini_set("log_errors", 1);

ini_set("error_log", "/tmp/php-error.log");

error_log( "Hello, errors!" );


Copy files from source to destionation server

   Source directory:  /var/www/html/example1/

        example1 folder contains sub folder and files

   Destination directory: /var/www/html/example2/

 Linux command

  scp -r example1/.   <username>@<hostname>:/var/www/html/example2/

 

compress file in linux command

tar -czvf  sample.gz  sample

tar -czvf  <compressfilename>.gz  <folder name>

 

 

 Unzip file in linux command

tar xzvf   <filename>.tar.gz

Remove files in Linux command

To remove all files & subdirectories from a directory (MS-DOS deltree like command), enter:

rm -rf test.txt

 Change Permission in Linux command

 

chown -R 48.48  drupal6/sites/default/files

chmod -R 755 drupal6/sites/default/files

 

Site not searchable in Google  drupal 6

Add the below code to drupal6/robots.txt file

Disallow: /


 

 


print array value in file using php

Posted by jaffar on September 10, 2013 at 2:10 PM Comments comments (0)

print an array in file

$a = array('a', 'b', 'c');

$handle = fopen('sample.txt', 'a');

fwrite($handle, print_r($a, TRUE));

Drupal Interview Question for Drupal 7

Posted by jaffar on August 3, 2013 at 11:55 AM Comments comments (1)

Some of the reference links

http://drupalor.com/2012/06/21/drupal-interview-questions-for-experienced-drupal-developer/

Core modules in drupal

https/drupal.org/node/1283408

OOPS in drupal

https/drupal.org/node/547518

Top 15 Permance tips drupal

http://www.netmagazine.com/features/top-15-drupal-performance-tips

PHP Interview questions

http://www.pcds.co.in/php-interview-questions-and-answer.php



Architecture: Site or Functionality

Posted by jaffar on July 24, 2013 at 2:45 AM Comments comments (0)

Site architecture includes how the site works, the number of modules, and how they interact.

Best Practice

Keep your site lean, using the minimal amount of code and fewest number of modules necessary. Use contrib

modules whenever possible rather than writing custom code. Become expert at key contrib modules, such as

Views and Panels. Follow Drupal standards for custom code. Reevaluate your architecture periodically.

Mistake: Too many modules. More than 200 modules indicates a need for analysis to be sure all are necessary.

Example 1: Original plan included multiple languages, but site ended up in English only.

Example 2: Original plan anticipated need for numerous roles, but most not used.

Solution: Reevaluate your site periodically, and disable or remove unused modules.

Mistake: Creating custom code when a contrib module already does the job well.

Example: Custom module to create forms on the fly that can be sent by email to site admins.

Solution: In this case, the well-tested Webform module provides this functionality, along with flexibility for site

admins. Be sure no contrib module already does what you need.

Mistake: Hacked core or contrib modules. Behavior will be unpredictable. Updating is difficult.

Solution: If core or contrib doesn’t do quite what you need, build a custom module using hooks to alter

behavior. If you inherit a site, use the Hacked! module to find altered code (see Recommended Tools).


 

Mistake: Custom code using the wrong hooks or using the Drupal API incorrectly.

Example 1: Using hook_init, which loads on every page, for something only used on the home page.

Example 2: Custom modules with hardcoded strings for nids, tids, and vids. When these change in the

future, troubleshooting the cause of resulting problems is very difficult.

Solution: Plan carefully when using custom code. Find the right hooks and syntax using drupal.org’s API

documentation at [http://api.drupal.org/api/drupal].

Recommended Tools:

Simplytest.me [http://simplytest.me].

On this site, simply enter the name of a Drupal module. The site will spin up a Drupal instance for you to test

the module for 30 minutes.

Hacked! module [http://drupal.org/project/hacked]

This module scans your Drupal installation, including contrib modules and themes, and determines if they

have been changed. Used with the Diff module, result screens will tell you the exact lines that have changed.

Not to be used on production sites.


Architecture: Display

Posted by jaffar on July 24, 2013 at 2:40 AM Comments comments (0)

5 Mistakes to Avoid on Your Drupal Website 4

Architecture: Content

Content is the essence of your website, the reason it exists. Determining the structure of content is the first

step in creating website architecture.

Best Practice

Plan your content structures, including fields and content types. Clear content architecture helps ensure

good performance, a better user experience, and easier maintenance.

(You may find overlap here with Display Architecture, because Views often depend on certain content

types.)

Mistake: Too many content types.

Result: This will confuse content creators.

Example: Content types “news” and “article,” which are almost identical.

Solution: Reuse and standardize content types.

Mistake: New fields created for every content type.

Result: This is a waste of resources and drain on performance.

Example: Two different fields for school city and teacher city.

Solution: Reuse and standardize fields. Check your field report at example.com/admin/reports/fields.

Mistake: Content types with no nodes.

Result: An unneeded content type adds unnecessary complexity.

Solution: Reassess your needs as you build the site. Filter your content list to identify unused content

types. Move content and delete unneeded content types.


-------------------------------------


 

Introduction

Drupal is one of the most flexible content management systems in existence.

This eBook provides best practices in five crucial areas of building and maintaining an effective

Drupal site.

Acquia’s consulting staff has discerned patterns of mistakes as they have audited numerous Drupal

sites. In this eBook, you’ll benefit from lessons learned through those Acquia site audits.

ŽŽ Architecture: This category covers best practices for structuring content, how to build the display,

and how to organize functionality.

ŽŽ Security: How to avoid specific types of attacks, as well as Drupal best practices that help protect

a site.

ŽŽ Performance: Tools for performance analysis, common approaches to optimizing your site, and

caching mistakes to avoid.

ŽŽ Infrastructure: Best practices for your software stack, including Varnish and Memcached layers.

ŽŽ Website life cycle: How to set up best practices throughout the life of your site, including

development, deployment, and maintenance phases.

This eBook assumes that you are familiar with Drupal site building and that you know PHP, Drupalspecific

programming, such as hooks, and the MySQL database.


Architecture: Content

Posted by jaffar on July 24, 2013 at 2:40 AM Comments comments (0)

Architecture: Content

Content is the essence of your website, the reason it exists. Determining the structure of content is the first

step in creating website architecture.

Best Practice

Plan your content structures, including fields and content types. Clear content architecture helps ensure

good performance, a better user experience, and easier maintenance.

(You may find overlap here with Display Architecture, because Views often depend on certain content

types.)

Mistake: Too many content types.

Result: This will confuse content creators.

Example: Content types “news” and “article,” which are almost identical.

Solution: Reuse and standardize content types.

Mistake: New fields created for every content type.

Result: This is a waste of resources and drain on performance.

Example: Two different fields for school city and teacher city.

Solution: Reuse and standardize fields. Check your field report at example.com/admin/reports/fields.

Mistake: Content types with no nodes.

Result: An unneeded content type adds unnecessary complexity.

Solution: Reassess your needs as you build the site. Filter your content list to identify unused content

types. Move content and delete unneeded content types.

Drop Primary key and add primary key in Drupal 6

Posted by jaffar on June 9, 2013 at 1:45 AM Comments comments (0)

  How to set primary key in by using modules in drupal 6.  The below code is used to execute the primary key in a table

section_sidebar is a table name  sbid is the primary key of the table section_sidebar

 

<?php

$ret = array();

db_drop_primary_key($ret, 'section_sidebar');

db_add_primary_key($ret, 'section_sidebar', array('sbid'));

 

db_drop_index($ret, 'section_sidebar', 'sidebar_block_w_h');

db_add_index($ret,'section_sidebar', 'sidebar_block_w_h', array('weight', 'hide'));


?>

 

 


Rss_feed