How do I add my own custom Javascript in Drupal 8?

 Save your custom script in themes/THEMENAME/js/script.js


 Declare your script in themes/THEMENAME/THEMENAME.libraries.yml:
 ts-corescripts:
   version: VERSION
   js:
     js/script.js: {}


 In THEMENAME.theme
 <?php
      /**
         * Add custom scripts
         */
        function THEMENAME_page_alter(&$page) {
          $page['#attached']['library'][] = 'thirstysix/ts-corescripts';
          //$page['#attached']['library'][] = 'core/jquery';
        }
    ?>


 

Translate a JS string from Drupal interface translations

Translate a JS string from Drupal interface translations

Drupal.t()

Drupal.t("My String");

Clear the Drupal Cache.

This string appear in /admin/config/regional/translate

if not then check your libraries.yml file 
And add the corresponding dependencies THEME.libraries.yml:
dependencies:
  - core/jquery
  - core/drupal

Enjoy :)

Drupal Bartik Admin - Drupal Super Admin theme as a Batrik theme

Drupal Bartik Admin-Super admin theme forever.

It's just an emerging product. As a bartik, we have to always configure the superadmin. The software settings may be overridden if you need to. It will only be open to the superadmin useruid 1.

The admin pages will be overridden by super admin theme as batrik. Drupal lets you identify a specific Admin Pages theme.

URL: https://www.drupal.org/project/bartik_admin

Admin pages are in English Drupal?

All Admin pages are in English and admin menu always in LTR?

1) First go to Administration -> Configuration -> Regional and language -> Languages -> Detection and selection tab and make sure to have “Account administration pages“ enabled.

2) Then go to People and edit your user. Admin -> Edit Profile -> Edit

Go down to the Language settings section. You should now see a Administration pages language dropdown. 

Select and save.

3) Go to the administration language using the following settings:

url: /admin/config/regional/language/detection

"Account administration pages" - Enabled

"Follow the user's language preference." - Enable

and drag and drop to the top position.

Drupal Multisite Setup on a XAMPP with Localhost

Install a XAMPP on your local machine.  Followed recommendations to not install in program files as there is some firewall problems. (e.g., c:\xampp)

Install a Drupal 8 instance that will act as the root site for our multisite instance. In our example, the root site will be called drupal8multisite, will be reachable at drupal8multisite.com, and will be installed at /xampp/htdocs/drupal8multisite

100+ Drupal Questions and Answers

I hope this helps you get Drupal Questions and Answers. If you have any queries/modifications/best answers or if something went wrong kindly post your content in the comment section. So, it will helpful to others.Thanks.

“Doing nothing for others is the undoing of ourselves.” 
― Horace Mann

“You need an attitude of service. You're not just serving yourself. You help others to grow up and you grow with them.” 
― David Green

Create a Blog website using SimpleBlog Drupal8 Theme.

#SimpleBlog

SimpleBlog is Drupal 8's new, clean grid-responsive theme, focused on the site.

Drupal8 Themehttps://www.drupal.org/project/simpleblog

Easy Blog is a light weight, 3 column design. It is a simple drupal theme for starting a grid-system blog.

SimpleBlog Features:

  • Responsive Feature
  • Simple design
  • EasybGrid Layout
  • With/without Grid Layout 
  • Supports 3 layout

Where are Drupal8 contact forms entries stored?

Contact form

Contact Storage module will provide storage for Contact messages which are fully-fledged entities in Drupal 8.

This plus core contact module aim to provide functionality equivalent to the base-features of Webform or Entity Form.

Contact Storage

https://www.drupal.org/project/contact_storage

Contact Storage module provides storage for all the messages submitted through the forms on your site as well as views integration to manage them.

URL redirect rewrite using the .htaccess file

Create a 301 redirect for all http requests that are going to the old domain to new domain

If you are wanting to only redirect a specific subdomain, you would do something like this:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^olddomainname.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www.olddomainname.com$
  RewriteRule (.*)$ http://www.newdomainname.com/$1 [R=301,L]
</IfModule>

[or]
  
Redirect  301 /olddomainname http://www.newdomainname.com

Integrate Instagram Without API + Drupal 8

#InstagramWithoutAPI

It is a very simple module that interacts with Instagram without an API and creates a block containing your latest messages from Instagram.

To send bug reports and design feedback or to track changes: https:/www.drupal.org/project/issues/instagram without api Go to Block Design to attach Instagram Block to specific content region.
I.e Home-> Admin-> Structure-> Block.

You must also add the Instagram account user name as part of the block setup to pull posts.

MODULE URL: https://www.drupal.org/project/instagram_without_api

 

Drupal Theme Hook Suggestions

Theme hook enables any module or theme to provide suggestions for alternative theme feature or template name suggestions and reorder or remove suggestions.

Drupal 7:

<?php
/**
* Implements hook_preprocess_HOOK() for node templates.
*/
function MYTHEME_preprocess_node(&$variables) {
  $variables['theme_hook_suggestions'][] = 'node__' . 'first';
  $variables['theme_hook_suggestions'][] = 'node__' . 'second';
}

Drupal 8:

<?php
/**
* Implements hook_theme_suggestions_HOOK_alter() for node templates.
*/
function MYTHEME_theme_suggestions_node_alter(array &$suggestions, array $variables) {
  $suggestions[] = 'node__' . 'first';
  $suggestions[] = 'node__' . 'second';
}