Drupal Dump

Drupal Snippets, Hacks and more....

413 posts since 2011

Add JS code to header tag of html

Reading docs about drupal_add_js you might think you can add JS to header of html, but only thing you can choose is header or footer of your theme (as region), to add JS to header tag, you need to use 

How many database tables do nodes and entities produce depending on settings

In this post I will determine how many DB tables does each option you choose make.
 

Lets start with NODE, make a basic node, with just title and body, when we enter data for it, it will populare 6 tables.

1. node
2. node_revision
3. node__body
4. node_revision__body
5. node_field_data
6. node_field_revision

Properly setup redirects from www to non-www on nginx

In many online tutorials you will find just few lines like 

server {
    server_name www.example.com;
    return 301 $scheme://example.com$request_uri;
}

but actually you need much more, you need to include SSL certificates, otherwise you will get message about insecure site so you should have this

Auto indent lines with vim

Type this to auto format a messed up file when editing with VIM

So, gg to get the start of the file, = to indent, G to the end of the file, gg=G.

Change FQDN on server

You'll want to edit /etc/hostname with your new hostname, so just go and change it and then update your /etc/hosts with

127.0.0.1 localhost
1.2.3.4 your-new-hostname