Creating hierarchical tree in Drupal using view org charts.

How to edit woo commerce template by custom coding
September 28, 2016
Import Data To Field Collection Using Feed Importer | Drupal
April 15, 2017

Creating hierarchical tree in Drupal using view org charts.

For better understanding your business and the peoples working under you with details, we generally need to view the hierarchy and the peoples involved in each hierarchy. Creating hierarchical tree is an important task while creating any organization based software/site.

caption:1The organization chart is helpful in showing the relation of one official to another of a company in graphical manner. It is also used to show the relation of one department to another or of one function of an organization to another. This chart is valuable in such a way that it enables one to visualize a complete organization within him/her, by means of the picture it presents. Here we understand how it works using Drupal.

Installation:

  •  Install views Org charts module.
  • Enable the given module (you need to enable reference, views, node reference and Library module for
    smooth working of the module).
  • First download Goolge Api js file from here and place it into libraries directory under sites/all/libraries/google_api/(paste the js file code in this file ->google_chart_api.js )
  • Now we can create hierarchy in two ways:

     a) Hierarchy of nodes. (nodes created using a specific content types)
     b) Hierarchy of users. (user created using admin->people->add users)

Let us go in detail of each:-

a) Hierarchy of nodes
We can create the hierarchy of nodes of a content type by using node reference with following steps.

1. Create content type (eg. org chart).

2. Add a new field (eg. org node reference) and select node reference as a feild type.Also select a proper
widget for it as shown below(pic. 2).

2nd-steep3. Add some data to the content type which you want to be visible in hierarchy.

4. Create a new view of that content type=(eg. org chart),add the required fields and select view format as
“views Org chart” and go to its settings.

5. Enter the field name(which you provided as node reference in your content type) in parent id as shown
below(pic. 3)
p3
6. In the primary key box, select the id referring to parent node which you provided in parent field.
7. save the view and check the page. Add the fields according to your requirements.

b) Hierarchy of users

We can create the hierarchy of users of a system by using user reference with following steps.

1. Go to config-> people-> account settings->
2. Add a field (provide field type as user reference).It will be used as parent id. User will refer
himself to this field as shown in given image.

add-a-field
3. Add some user and whom you want to be visible in hierarchy.
4. Create a new view of user type , add the required fields and select view format as “views Org chart” and
go to its settings.
5. In parent id enter the field name(which you provided as user reference in account settings) as shown
above(pic. 3)
6. In the primary key box, select the id referring to parent node(eg. uid) which you provided in parent
field.
7. Note: Go to configuration of uid field(or another primary key field) and uncheck “link this field to the
user”. as shown below(pic. 4)

pic-5
8. save the view and check the page. Add the fields according to your requirements.

Comment below for further queries of Drupal.

Like us on facebook, follow twitter Subscribe to youtube for further such updates.

Leave a Reply

Your email address will not be published. Required fields are marked *

three × 3 =