Thursday, December 4, 2014

Implement Jquery infinite scroll plugin

Plugin Source: https://github.com/paulirish/infinite-scroll/

Automatic Scroll:
$('selector').infinitescroll(options);

 Manual Scroll:
$('#scroll-container').infinitescroll(options);
$('#scroll-container').infinitescroll('unbind');

$('.view_more').click(function() {
    $('#scroll-container').infinitescroll('retrieve');
    return false;
});

Note:
You may have to add the manual trigger behavior if you are working with masonry or isotope in order to make it work. Just include manual-trigger.js after infinitescroll and pass the behavior by passing behavior: 'twitter' when calling the plugin.

Monday, October 27, 2014

GIT shows warning when pull

GIT shows warning when pull. If you are getting the below warning message when GIT pull

(gnome-ssh-askpass:29014): Gtk-WARNING **: cannot open display:

Please use "unset SSH_ASKPASS"



Friday, October 10, 2014

Show new products list on homepage in Magento

Please follow the below steps to showing the new products list on homepage in Magento.






1. Admin -> CMS -> Pages
2. Edit "Home page" content
3. Click "Content" tab
4. Press "Show/Hide editor"
5. Click "Insert Widget"
6. Choose "Catalog New Products List" from Widget type drop down
7. Ans choose "Widget Options"
8. Done. Insert Widget




Wednesday, October 8, 2014

Magento admin login not working

There is the problem with session cookie. So open the /app/code/core/Mage/Core/Model/Session/Abstract/Varien.php file and comment out the line

//'domain'   => $cookie->getConfigDomain(),
//'secure'   => $cookie->isSecure(),
//'httponly' => $cookie->getHttponly()

Drupal8 Beta1 install problem

If you are getting PHP Extension while install problem in Drupal8 Beta1, Please uncomment  extension=php_fileinfo.dll on php.ini file.

This will work.

Monday, September 22, 2014

Path url alias change in Drupal

use hook_pathauto_alias_alter() to change the url path alias in Drupal.

hook_pathauto_alias_alter(&$alias, array &$context)

$alias - Alias of the path
$context - It can be node, user...etc

Thursday, September 18, 2014

Big differences between GIT and SVN

1. GIT is distributed version controller, SVN is not
GIT is more intended to be used in distributed mode which means, every developers checking out code from central repository/server will have their own cloned repository installed on their machine. If you are stuck somewhere where you don’t have network connectivity, like inside the flight, basement, elevator etc., you will still be able to commit files, look at revision history, create branches etc. But SVN should have internet connection to commit files to repository.

2. GIT branches are not the same as SVN branches
Branches in SVN are nothing but just another folder in the repository.
GIT branches is much more easier & fun. You can quickly switch between branches from the same working directory. It helps finding un-merged branches and also help merging files fairly easily & quickly.

3. GIT’s content integrity is better than SVN’s
SHA-1 cryptographic hash function is used for maintaining data integrity in GIT.

How to show terms in a Views in its hierarchical structure or tree structure?

We can show the taxonomy terms as hierarchical structure or tree structure by using views.
For example:


Vechicle is Vocabulary

      Car
            Honda
            Audi
            BMW
            Maruthi Suzuki
                  Marithi
                  Suzuki
      Bike
            Hero Honda
                  Hero
                  Honda
            Hero
            TVS
            Bajaj
      Bus/Lorry
            Ashok Layland
            Volvo
            Benz


Answer:

We can use Views Tree or Views Field View module to handle this kind of tree structure.

Please follow the below steps to show a taxonomy terms as tree view, by using Views Field View

1. Add new view (View name, Show -> Taxonomy terms, Either Page or Block display)
2. Add Relationship for "Taxonomy term: Parent term" name as "Parent" in Advanced section
3. Add Fields : Taxonomy term: Name (without relationship), Taxonomy term: Name(Parent relationship, excluded it from display)
4. Check or Add Filter Criteria "Taxonomy vocabulary: Machine name" to vocabulary name
5. Add Filter Criteria "Taxonomy term: Parent term" (with Parent relationship) equal to 0. (show only level 2)
6. In Format settings, Grouping field Nr.1 with field (Parent) Taxonomy term: Name.(to display level 1)
7. Add Sort Criteria, "Taxonomy term: Weight" (with Parent relationship) to Asscending order
8. Save it

The above steps to show the two level tree structure. If you want to show three level tree structure, then you have to add the below steps,

Enable Views Field View module

9. Add A new display (an attachment is good)
10. Override its fields (just click any field, choose this attachment(overridden) from the select box on top, and then save the field. (this is to avoid recursion)
11. Override the attachment Contextual filters by adding Taxonomy term: Name (Parent relationship)
12. Add a view field (Global: View) to your view fields in the first first view.
13. Use the attachment in the view field config, and add the token for the term name (not the parent) as the contextual filter value sent to the attachment.
14. You can remove the relationship from the filter in step 4, this will display the top level in main display, so you can skip grouping (step 5), then add a new display for each level you want to display (control no. of levels to display)


Malformed image URL in Node Edport module in Drupal 7

If you are getting Malformed image URL in Node export. Then you have to change the code in Node Export module

Try to use image_create_url() instead of url() in node_export.module file: Line 1052

- $export_data = url($file->uri, array('absolute' => TRUE));
+ $export_data = file_create_url($file->uri, array('absolute' => TRUE));

Monday, March 17, 2014

Get the file size in Drupal

The following function is used to return the file size,

$file = file_load($fid)
echo filesize(drupal_realpath($file->uri));

url - it will return the file public url (public://filname.ext)
file_create_url() - it will return there relative url of the file (http://localhost/sites/default/files/filname.ext)
drupal_realpath() - it will return the absolute url of the file path.(sites/default/files/filename.ext)



Thursday, March 13, 2014

Find the text or value in MYSQL table using REGEXP

We can use REGEXP command to find the string value in MYSQL table.
SELECT * FROM <table> WHERE <column> REGEXP '<string>';

Ex: SELECT * FROM watchdog WHERE message REGEXP 'message'

Monday, February 24, 2014

Delete operation in Drupal 7

The following function is used to delete file and file usage in Drupal 7.
file_data($file);

The following db function is used to delete a record from a table in Drupal 7.
db_delete('table')->condition('field', $value->execute();

The following drupal function is used to delete a node in Drupal 7.
node_delete($nid);
Multiple node delete: node_multiple_delete(array($nid1, $nid2));

The following drupal function is used to delete a user in Drupal 7.
user_delete($uid);
Multiple user delete: user_multiple_delete(array($uid1, $uid2));

The following drupal function is used to delete a content type in Drupal 7.
node_type_delete($type);

Friday, February 21, 2014

Use file_prepare_directory() instead of file_check_directory()

In Drupal 7, use file_prepare_directory() instead of file_check_directory() from Drupal 6.

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);