- http://
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = array( | |
'Harju maakond' => array( | |
'Anija vald', | |
'Harku vald', | |
'Jõelähtme vald', | |
'Keila linn', | |
'Kiili vald', | |
'Kose vald', | |
'Kuusalu vald', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$image = \Drupal::service('image.factory')->get($file->getFileUri()); | |
$image_style = \Drupal\image\Entity\ImageStyle::load('gallery_large'); | |
// Set source image dimensions. | |
$dimensions = [ | |
'width' => $image->getWidth(), | |
'height' => $image->getHeight(), | |
]; | |
// After calling this, the $dimensions array will contain new dimensions. | |
$image_style->transformDimensions($dimensions, $file->getFileUri()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$date = DrupalDateTime::createFromFormat(DATETIME_DATETIME_STORAGE_FORMAT, 'datetime string', DATETIME_STORAGE_TIMEZONE); | |
$date->setTimeZone(new DateTimeZone(drupal_get_user_timezone())); | |
$date->format('d.m.Y H:i'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_form_FORM_ID_alter(). | |
* | |
* Add wysiwyg editor to term translation. | |
*/ | |
function module_form_i18n_string_translate_page_form_alter(&$form, $form_state) { | |
$keys = array_keys($form['strings']['all']); | |
$first = reset($keys); | |
if (strpos($first, 'taxonomy:term:') !== FALSE) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change error messages order. | |
* | |
* We need to change the error messages order, because it's wrong. To do that, | |
* the session array must be modified. It's not nice, but gets the job done. | |
*/ | |
function my_module_validate_messages_order($form, $form_state) { | |
$errors = form_get_errors(); | |
// Skip, if there isn't any form errors. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$query = new EntityFieldQuery(); | |
$query->entityCondition('entity_type', 'node') | |
->entityCondition('bundle', 'article'); | |
$result = $query->execute(); | |
if (isset($result['node'])) { | |
$nodes = entity_load('node', array_keys($result['node'])); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_theme_preprocess_page(&$variables) { | |
if ($variables['main_menu']) { | |
// Build links. | |
$links_source = variable_get('menu_main_links_source', 'main-menu'); | |
$tree = menu_tree_all_data($links_source, NULL, 1); | |
menu_tree_add_active_path($tree); | |
$variables['primary_nav'] = menu_tree_output($tree); | |
// Provide default theme wrapper function. | |
$variables['primary_nav']['#theme_wrappers'] = array('menu_tree__primary'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (conf_path() != 'sites/default') { | |
$menus = array( | |
'menu-main-menu-bg', | |
'menu-main-menu-cs', | |
'menu-main-menu-de', | |
'menu-main-menu-fi', | |
'menu-main-menu-hr', | |
'menu-main-menu-hu', | |
'menu-main-menu-pl', | |
'menu-main-menu-ro', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function THEME_preprocess_html(&$variables) { | |
$panels = page_manager_get_current_page(); | |
$variables['classes_array'][] = (!$panels ? 'not-' : '') . 'panels-page'; | |
} |
NewerOlder