Hot answers tagged

4

I think you cannot have a module hook executed the same hook implemented by a theme. If we look at the hook invoking code, we see that the theme hooks are invoked separately and after the module hooks. The best bet would be to remove it from the theme and put it in a module, or trying with #after_build. FormBuilder.php contains the following code. $this-&...


2

Where my confusion comes in is when I go to specify parameters or document the function. What parameters does the function take? What hook does it implement? Preprocess hooks are only provided a single parameter: $variables. The hook that you're implementing is literally hook_preprocess_HOOK. The HOOK part of it is the identifier for the theme entry, as ...


2

You should be able to do it like this: <?php use Drupal\taxonomy\Entity\Vocabulary; /** * create vocabulary testname. */ function ent_create_update_8105(&$sandbox) { $vid = 'testname'; $vocabulary = Vocabulary::load($vid); if (!isset($vocabulary)) { Vocabulary::create([ 'vid' => $vid, 'description' => '', 'name' =...


2

No performance issue concerning the node entity, which is loaded only once per request and then stored in memory. For caching between requests there are also no performance issues, because the rendered twig template(s) of a block are cached by default. But you have to make sure you provide the correct cache data, which is possible via a plugin context in ...


2

A feature module is just another module. And you can enable it programmatically using the linked code from another enabled module's hook_update_N placed in this another enabled module's *.install file. This even can be another feature module. Then have this hook fired via drush updb on the command line or by visiting your site's /update.php. You also could ...


1

@yulvianda, By seeing your question it seems that you are not getting how to use the piece of code you have shared in your question. If that is the case, then you can use any of the following hooks of Drupal where you can check for your content type (like this: $node->getType() == 'name of the content type') and can put your code: hook_node_update / ...


1

I found a solution: call field_attach_view with the required language. /** * Implements hook_preprocess_node(). */ function MYMODULE_preprocess_node(&$vars) { if ($GLOBALS['language']->language == 'ru') { $original_langcode = 'en'; $content_original = field_attach_view('node', $vars['node'], $vars['view_mode'], $original_langcode); //...


Only top voted, non community-wiki answers of a minimum length are eligible