Outside Links collection

Sometimes you find just the right resources that fulfill certain need and nothing much should be added to them, in those cases I will just collect them on this page and add short comment why is this so.

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

How to encode json with drupal_http_request in drupal 7

In lots of places you will see how to use drupal_http_request with drupal_http_build_query used on data, which is fine if you want to build regular query data (like the ones you have in URLs when using GET) but if you want to send JSON, you shouldn't use that, instead you need  json_encode function on data.

Solr search, where to find body field

By default body field of a content type will not be shown among the fields to index, which is kind of strange but that is how it is as many other properties and fields of content are there by default.

Advenced History command in linux / Mac OSx

Recently I started using history command a lot. Just to check what I have done. One thing missing by default is timestamp, I want to know when I did something so to do that you can do this 

Using try catch - php exceptions

Not many devs use try catch in custom code, especially in drupal 7. Thing is that it can save you from bigger problems if you wrap your (bad) code into that block, so lets just make simple example how to use it.

Flush image styles in drupal 7

To flush some image style, you can install module for that with UI, but you can also do it in lean way, with just drush php command or if locally with devel/php window. If using drush use this command

 drush php-eval '$style = image_style_load("optimize_original"); image_style_flush($style);'


What to use, text list or taxonomy term?

To force users or administrators to have predefined list of what to put into some field you will need to use one of this 2 solutions, text list or taxonomy term reference field.