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_views_pre_render(). | |
*/ | |
function MODULE_views_pre_render(&$view) { | |
if ($view->name == 'brand_page') { | |
$breadcrumbs = array(); | |
$breadcrumbs[] = l(t('Home'), '<front>'); | |
drupal_set_breadcrumb($breadcrumbs); | |
} | |
} |
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 template_preprocess_field | |
*/ | |
function THEME_preprocess_field(&$vars) { | |
// Display first image in colorbox gallery preview. | |
if (isset($vars['element']['#field_name']) && $vars['element']['#field_name'] == 'field_product_image') { | |
if (isset($vars['items'][0]['#theme']) && ($vars['items'][0]['#theme'] == 'colorbox_image_formatter')) { | |
$first_photo_copy = $vars['items'][0]; | |
// Disable copy image in gallery, use only for preview. |
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_factory = \Drupal::service('image.factory'); | |
$image = $image_factory->get($file->getFileUri()); | |
if (!$image->isValid()) { | |
} |
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_field_attach_view_alter(). | |
*/ | |
function MODULE_field_attach_view_alter(&$output, $context) { | |
foreach (element_children($output) as $field_name) { | |
if ($field_name == 'field_cmrc_price_table') { | |
// If min and max price have the same value, then display price without range. | |
if (isset($output['field_cmrc_price_table'][0]['#markup']) && !empty($output['field_cmrc_price_table'][0]['#markup'])) { | |
$separated_price = explode('–', $output['field_cmrc_price_table'][0]['#markup']); |
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
$this->state->resetCache(); | |
$this->state->set("current_community_{$this->current_user->id()}", $community_id); |
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
$form['preview']['cancel'] = [ | |
'#type' => 'link', | |
'#title' => $this->t('Cancel'), | |
'#url' => \Drupal\Core\Url::fromRoute('<current>'), | |
'#options' => [ | |
'attributes' => [ | |
'class' => [ | |
'btn', | |
'btn-primary', | |
'btn-one-row', |
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
$output['#attached']['library'][] = 'core/drupal.dialog.ajax'; |
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
$entity_update_manager = \Drupal::entityDefinitionUpdateManager(); | |
$entity_type = $entity_update_manager->getEntityType('bs_mail_logger'); | |
$entity_update_manager->uninstallEntityType($entity_type); |
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
public static function getMonthInterval($date) { | |
$month_interval = []; | |
// Get start month date. | |
$date_obj = new \DateTime($date); | |
$date_obj->modify('first day of this month'); | |
$month_interval['start'] = $date_obj->getTimestamp(); | |
// Get end month date. | |
$date_obj->modify('last day of this month'); |
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 | |
use Drupal\Core\Database\Database; | |
use Drupal\group_revision\GroupRevisionTrait; | |
/** | |
* Implements hook_install(). | |
*/ | |
function group_revision_install() { | |
// Update entity fields. |