Twig Snippets

This is a collection of my most used Twig snippets, developed with Twig 1.8. // Urlify simple filter for Twig $filter = new Twig_SimpleFilter('urlify', function ($string) { return URLify::filter($string); }); $twig->addFilter($filter); // Example: {{...

read more

Drupal Snippets

// Get drupal's root url $GLOBALS['base_url'] => http://example.com/drupal base_path() => /drupal/ request_uri() => /drupal/documentation?page=1 request_path() => documentation current_path() => node/26419 // Print Views Block from Node TPL + Pass...

read more

PHP CIDR To Range Reader Function

function cidrToRange($cidr) { $range = array(); $cidr = explode('/', $cidr); $range[0] = long2ip((ip2long($cidr[0])) & ((-1 << (32 - (int)$cidr[1])))); $range[1] = long2ip((ip2long($cidr[0])) + pow(2, (32 - (int)$cidr[1])) - 1); return $range; }...

read more
Share This