CMS Self Service

The purpose of this document is to showcase the customization examples and the implementation details of these customizations done on the CMS base platform release.

Expose Categories Widget

Expose a categories widget in home page to list the categories and link to catalog that will display the services in the selected category.

Solution:

Create a view in CMS using Taxonomy Terms of Type Service Category.

Pre-requisites:

A Taxonomy for category exist in CMS with categories terms and category logos configured.

Technical Expertise:

  1. Basic Drupal Knowledge.
  2. Knowledge about Views, Blocks and Taxonomy.
  3. CSS knowledge to style the view.

Reference Links:

Implementation Details:

  1. Create a new Block View in CMS using Taxonomy Terms of Type Service Category.

  2. Add fields Logo.
  3. Add Taxonomy Term: Name and link path catalog?f[0]=field_category%3A[tid].
  4. Add Filter Taxonomy vocabulary: Machine name (= Service Category) & Sort criteria Taxonomy term: Name (asc).
  5. Add Relationships, Taxonomy term: Representative node.
  6. Save the View.
  7. Add the new Block created using the above view in the Region where it needs to be displayed for the theme in Structure > Blocks.

Show Trial badge and Starting Price in Service Listing

Show a Trial badge for the services having trial and show starting price in catalog service tiles.

Solution:

Add New fields in CMS Service configuration and update the catalog view to add these new fields.

Pre-requisites:

Content Type for Products and a view created for Catalog page.

Technical Expertise

  1. Basic Drupal Knowledge.
  2. Knowledge about Views, Content Types & Search API.
  3. CSS knowledge to style the view.
Reference Links
  1. https://www.drupal.org/docs/7/modules/views/what-is-views
  2. https://www.drupal.org/docs/7/understanding-drupal/content-types
  3. https://www.drupal.org/docs/7/modules/search-api
Implementation Details:
  1. Add New fields to capture the Trial Available flag and Starting price for the Product Page content type.
  2. Add the newly created fields to index in Search API settings. The catalog view is generated based on the indexed fields.
  3. Edit the catalog view.
  4. Add the Indexed Node Trial fields to the view and hide from display.
  5. Add a new php field, and add the code to check if the trial available value is there to display the badge.
    <?php 
    $node = node_load($data->entity);if(isset($node->field_trial_available_['und'][0]['value']) && $node >field_trial_available_['und'][0]['value'] == 1){
    print '<div class="freetrial">'.t("Free Trial").'</div>';
    }
    ?>
  6. Add the Indexed node price starting from.

  7. Save the View.

Show Auto Suggestion for the Service Search Box

Extend the available service search field to auto suggest services while typing.

Solution:

Query the Database to get the suggestions while typing and display along with the search box.

Pre-requisites:

Existing search box to search services in catalog.

Technical Expertise
  1. Advanced Drupal Knowledge.
  2. Knowledge about Modules, Drupal Query creation.
  3. CSS & HTML knowledge to style the view.

Reference Links:

  1. https://www.drupal.org/docs/7/creating-custom-modules
  2. https://www.drupal.org/docs/7/api/database-api/dynamic-queries/introduction-to-dynamic-queries
Implementation Details:
  1. Create a CMS menu to receive the typed string and process.
  2. Attach a JavaScript keyup event to the search textbox.
  3. In the event keyup handler, get the textbox value and post it to the new CMS menu created using Ajax.
  4. Build the Drupal Query for the product node titles like the search string.
    $query = db_select('node', 'n');
    $query->join('field_data_field_service_id', 'field_data_field_service_id', 'n.nid = field_data_field_service_id.entity_id');
    $query
    	->fields('n', array('nid'))
    	->condition('n.title', '%' . db_like($key) . '%', 'LIKE')
    	->condition('n.type', 'product_page')
    	->condition('n.status', '1');
     $db_or = db_or(); 
    foreach($serviceIds as $serviceId){
    $db_or->condition('field_data_field_service_id.field_service_id_value',$serviceId,'='); 
    }
    $query->condition($db_or);
    $query
    	->orderBy('n.created', 'DESC')
    	->addTag('node_access');
    $result = $query->execute()->fetchCol();
  5. Pass the results to the script and build the suggestions.