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