Drupal

Difference between memcache and varnish?

  Memcached can be used as an in-memory, distributed back-end for your application cache.
  Varnish can be used as a reverse proxy to externally cache HTTP requests.

  It seems to me that Varnish is behind the web server, caching web pages and doesn't require change in code, just configuration.
  On the other side, Memcached is general purpose caching system and mostly used to cache result from database and does require change in get method (first cache lookup).

Creating custom hooks in Drupal?

1) Alter hooks
   a common way to edit the contents of a particular object or variable by settings     variables in the hook by reference, typically by using drupal_alter()

2) Intercepting hooks
  Allowing external modules to perform actions during the execution, cannot get variables by reference, typically by using module_invoke_all(), module_invoke()

a) Simple invoking:
---------------------------
module_invoke_all() => Calling all modules implementing the hook

Drupal Template Structure

HTML
|->  HTML Head
|->  Page
      |-> Node
              |-> Field
              |-> Field
              |->Node Links
              |->Comment Wrapper
                    |-> Comment
                    |-> Comment
                    |-> Comment
      |-> Region
            |-> Block
            |-> Block

Preprocess Functions (theme_hook) Drupal

Allow one module to alter the variable used by another module when it call a theme hook.

template_preprocess_node(&$variables) 
  -> Process variables for node.tpl.php

template_preprocess_page(&$variables)
   -> Process variables for page.tpl.php

[module]_preprocess_[theme hookname]  (&$variables)

multi-hook preprocess functions
[module]_preprocess (&$variables, $hook)

Order of preprocess execution
-------------------------------------
All Preprocess functions run before all process functions

What is Entity?

* Entity provide unified way to work with different data units in Drupal.
* Entity is an instance of an entity type defined in Drupal.
* Drupal 7 is all about entities. They are everywhere nodes, users, comments, taxonomy terms.
* Drupal 6 field system was only used on content types. but now, field-able entities makes Drupal more flexible.
* Drupal 8 provides two entity types: 1) Configuration entity 2) Content entity

Entity Types >> Bundles >> Fields >> Entities