Attach css and js on specific templates in drupal 8

Want to load some specific js and css on particular twig template of drupal 8 ?

Don't worry, you are on the right page.

How to do it :

1. Go to your theme_name.libraries.yml file create a new library in this file for example post the following code:

test-library:
  version: VERSION
  js: 
     https://maps.googleapis.com/maps/api/js?sensor=false: { type: external, minified: true }
     /libraries/jquery.auto-complete.min.js: {}
    

2. Now got to your template(twig template) and paste following code at starting of file:

Manage drupal 8 configurations in version control

This was seems to be nightmare for us when multiple persons working on a single website not locally but on hosting server.

One night, i was going through drush commands, in the end i found some beautiful drush commands:

Those were :

drush cim

druhs cex

Which mean drush configuration import and drush configuration export.

What i did for for making configuration in git:

1. Created a drupal website on my local and add it to the git.

Embed View in Drupal 8

As we are new to drupal 8 things are changed in Drupal 8 as compared to Drupal 7.

Today i am showing how to embed a view in block or in a view. It is very easy.

In drupal there is function :

views_embed_view($view_name, $display_id, $contextual_filter)

create a custom module, in .module file create your own function.

I created the following function:

function snehi() {
  $view_content = views_embed_view('banner', 'block_1');
  print render($view_content);
 }

Unable to negotiate with 140.211.10.43: no matching key exchange method found.

I just created a sandbox project on drupal.org. I was getting following error.

Unable to negotiate with 140.211.10.43: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
fatal: Could not read from remote repository.

How to resolve this: please run following command to overcome this error.

export GIT_SSH_COMMAND='ssh -o KexAlgorithms=+diffie-hellman-group1-sha1'

Happy developing.

Install Drupal Commerce on Drupal 8

I am just done with Drupal Commerce Installation on drupal 8.
I followed these steps:
1.Point to Drupal 8 root folder

cd /var/www/html/D8

2.Install commerce module

drush dl commerce

It has following dependencies:
entity
inline_entity_form
profile
address
state_machine

drush dl entity
drush dl inline_entity_form
drush dl profile
drush dl address
drush dl state_machine
cd modules/commerce

9. Now install dependencies with composer install.

Pages

Subscribe to Davinder Kumar RSS