View paragraph_id_from_field_template.php
This file contains 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
$field['#object']->entity_id(); |
View load_node.php
This file contains 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
$route_name = \Drupal::routeMatch()->getRouteName(); | |
if ($route_name == 'entity.node.canonical') { | |
node = \Drupal::routeMatch()->getParameter('node'); | |
$node_type = $node->getType(); | |
$title = $node->getTitle(); | |
$visible = $node->isPublished(); | |
$node->setPromoted(TRUE); | |
$uid = $node->getOwnerId(); | |
// $author will be user object of the person who created the node. |
View resize_window_size.js
This file contains 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
$(window).on('debouncedresize', function() { | |
var win = $(this); | |
if (win.width() > 768) { | |
$footerMenuContent.find('li:hidden').show(); | |
} else { | |
$footerMenuContent.find('> .menu > li:not(.first)').hide(); | |
} | |
}); |
View delete_field_instance_using_hook_ni_D7.php
This file contains 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
/** | |
* Delete field instance field_journey_image_type. | |
*/ | |
function YOUR_THEME_journey_module_video_update_7001() { | |
$field_journey_image_type = field_info_instance('paragraphs_item', 'field_journey_image_type', 'journey_module_video'); | |
if (!is_null($field_journey_image_type)) { | |
field_delete_instance($field_journey_image_type); | |
field_purge_batch(1); | |
} |
View add_classes_to_views_rows.php
This file contains 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_view_unformatted(). | |
*/ | |
function YOUR_THEME_preprocess_views_view_unformatted(&$vars) { | |
$results = $vars['view']->result; | |
$iteration = 0; | |
foreach ($results as $key => $result) { | |
if (empty($result->field_image)) { | |
$vars['classes_array'][$key] .= ' empty__' . ($iteration % 5 + 1); |
View add_class_to_link_through_field_preprocessor.php
This file contains 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_preprocess_field(). | |
*/ | |
function YOUR_THEME_preprocess_field(&$variables, $hook) { | |
if ($variables['element']['#bundle'] == 'bundle_name') { | |
$link_attributes = &$variables['items'][0]['#path']['options']['attributes']; | |
// Add colorbox-node class to class attribute | |
$link_attributes['class'] = ['colorbox-node']; | |
View RouteSubscriber.php
This file contains 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 | |
namespace Drupal\custom_module\Routing; | |
use Drupal\Core\Routing\RouteSubscriberBase; | |
use Symfony\Component\Routing\RouteCollection; | |
/** | |
* Listens to the dynamic route events. | |
*/ |
View delete_field_using_hook_n_in_D8.php
This file contains 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 YOUR_MODULE_NAME_update_8001(&$sandbox) { | |
FieldStorageConfig::loadByName('paragraphs_type', 'example_field_name')->delete(); | |
FieldConfig::loadByName('paragraph', 'example_paragraph_name', 'example_field_name')->delete(); | |
} |
OlderNewer