Skip to main content

Posts

Showing posts from September, 2014

How to create a custom module in Drupal8 PSR-4? (Hello world module in Drupal 8)

Steps to create a custom module in Drupal8.  Step 1: File Structure.   In Drupal8 we should keep the Custom module or contributed modules under modules folder on the root directory.   modules/contrib/   modules/custom/   Note:- multisite configuration         sites/your_site_name/modules/   Here we have file structure, "modules/custom/example". Step 2: Creating .info.yml    In Drupal8 .info files changes to .info.yml   Here we have, example.info.yml Step 3: Creating .routing.yml    Before registering the hook_menu we have to write the path in  .routing.yml file.   In Drupal 8 we won’t need hook_menu() anymore as we make heavy use of the  Symfony2 components  to handle the routing. This involves defining the     routes as configuration and handling the callback in a controller (the method of a Controller class).   Here the example.routing.yml Step 4: Creating Route Controller Class   We have to create our ModuleController.php according to the  PSR-4 nam

How to add a 'related nodes' block that links to a taxonomy using views in Drupal 7?

1. Create an argument by adding the taxonomy field on which you want to find the related nodes. 2. Select "Provide default argument". 3. Argument type = "Taxonomy Term ID from URL" 4. Remove tick from "Load default argument from term page" 5. Tick the "Load default argument from node page, thats good for related taxonomy blocks." To remove duplicates you have to follow the following points. 1. Open "Query settings" in the "Advanced Settings". 2. Tick "Distinct". This gives you a perfect "Related Articles" or "Related Nodes" using Views.