Drupal

Using Laravel Valet with Drupal multiple sites

Setup of development environment for Mac is made easy with Laravel Valet. Comparing it with XAMPP setup, we don't need to edit hosts file and httpd.conf/httpd-vhosts.conf Apache configuration files to add a local development domain. Even Drupal multiple sites setup (sharing the same code base) is possible in Laravel Valet. In this article will discuss the Drupal multiple sites setup step by step guide and we will use local development domain http://webfoobar.test as Drupal site #1 and http://drupal.test as Drupal site #2.

Steps:

How to assign different separate domain for a Drupal page using Nginx

A client asked me to work on one particular page of his existing Drupal site to have its own different separate domain. This is one good solution if you have special web page that you want to quickly improve ranking on search engines.

Lets say, the http://www.webfoobar.com/node/88 is the page that we want it to have its own domain "test7.webfoobar.com". The following steps will accomplish this task:

Showing Drupal taxonomy terms' hierarchical structure in Views

This guide will show how to display Drupal taxonomy terms' hierarchical structure in Views. It is assumed that you have already existing setup of your own taxonomy terms hierarchical structure, a content type which has a field referencing your vocabulary with taxonomy terms hierarchical structure and posted nodes of this content type tagged with one of these taxonomy terms.

In this guide we will use the Drupal vocabulary that has the following structure as our example:

Solution to Drupal site's page's URL all contains its root path

I had a Drupal project where the website is hosted in shared web hosting and the issue was all its page's URL contains root path like for example: http://example.com/home/roland/public_html/contact (this URL should only be http://example.com/contact if without root path). We know that in shared hosting we don't have control in Apache web server's configuration files but we do only have the .htaccess to do some Apache stuffs. How can we remove the root path /home/roland/public_html from all our Drupal site's URL?

Display list of Drupal contents based on your visitor's state/province/region location in Views (using Smart IP and Location modules) and have a dropdown form available to filter other regions

In this article we will discuss how to setup a View that shows list of contents in a Drupal 7 site that are filtered based on your visitor's state/province/region location with the use of Smart IP and Location contributed modules and expose views filter to have a dropdown form available for visitors to enable them to filter list of contents in other regions. Smart IP module is used to identify Drupal site visitor's geographical location based on his IP address and Location module is used to provide the field and expose the views location filters.

Steps:

Solution on how to force re-index your Search API index application

The following codes below will just force to queue the node to your Search API index application batch process. But the actual index execution will not run yet and this depends on how often your cron runs.

  
// Clear field cache for the node.
cache_clear_all('field:node:' . $node->nid, 'cache_field');

// Reindex the node.
search_api_track_item_change('node', array($node->nid));
  

If you need to force index your Search API index application, you can use the codes below:

How to setup a working Responsive Image in Drupal 8

Responsive Image module is a core module in Drupal 8 and this guide will show setting up this module with working example.

Steps:

  1. Enable the Responsive Image module at http://www.yoursite.com/admin/modules.

  2. We can use existing Breakpoint group but in this guide we will create our own Breakpoint group. It can be created as module or as theme and we will create this as module. Inside /modules folder of your Drupal 8 site, create a folder labelled as "site_optimization".

Display downloadable files based on the country location of the visitor of a Drupal site's content

This article will show how to display downloadable files based on the country location of the visitor of a Drupal 7 site's content. We will take a sample application where the website's contents will have three types of downloadable files; first type should be displayed only for visitors from Philippines; the second type should be displayed only for visitors from Singapore and the third type should be displayed for visitors that are not from Philippines and Singapore (rest of the world) with the use of Smart IP, Field Collection and Location contributed modules.