drupal8

Drupal 8 - get blocks assigned to a region

Problem: There is no specific function in Drupal 8 which we can use to get all blocks assigned to a region. We used to have a function called block_get_blocks_by_region in Drupal 7 to do this

 

Solution : Although we don't have a specific function we have the tools in Drupal 8 s Object oriented hierarchy to do the same. Here is the code

 

function my_module_get_blocks_by_region($region) {

  $blocks = \Drupal::entityTypeManager()

    ->getStorage('block')->loadByProperties([

Drupal 8 Error when synching THEMENAME.settings

Problem

I cam across an error when synching configurations from my Drupal 8 local environment to my development environment. The error is as folllows

Error: configuration THEMENAME.settings depends on the THEMENAME extension that will not be installed after import.

Not entirely sure if this is a bug in D8 core but the root cause was that it when exporting the configurations from my local environment the "Configuration manager" module in D8 core was picking up an odd looking configuration. 
 

Enable Outside In experience in your Drupal 8 site

You might have seen the new users experience that Drupal 8 provides. Its provides on the fly block placement and menu configuration. The new experience is called "The outside in experience". Read more about it here. SO however if you are wondering how you can get hands on experience you need to do the following.

Pre-requisites:

You will need to update to Drupal 8.2.0

Modules to enable:

Place Blocks module

REST mode in Drupal 8

Submitted by nmeegama on Mon, 06/20/2016 - 10:32

As you might already know Drupal 8 contains a web services layer out of the box. Therefore we can now easily create a RESTful Architecture by exposing Drupal's data to a third party application. REST stands for Representational State Transfer. It is a set of design principles for making network communication more scalable and flexible.

Setting up debug mode on Drupal 8

  1. First copy sites/example.settings.local.php to default/settings.local.php
  2. Now uncomment the following lines in default/settings.php
    # if (file_exists(__DIR__ . '/settings.local.php')) {
    #   include __DIR__ . '/settings.local.php';
    # }
  3. Now debugging is set. You also can use the following command
    drupal routing:debug <route name>
    This command will give the user information regarding a specific route