New answers tagged

1

My problem was caused by a block existing only on dev and then configuration pointing to a block that did not exist elsewhere. It came up in Layout Builder. I'm on Drupal 8.7.6 and I was able to simply go in to the layout builder, remove the bad block reference, re-add the correct block and the problem was solved. I just had to be sure to re-export my ...


2

Yes that should be easy enough. In your view with the 100 projects you need to: 1)Add a relationship to the entity queue but DON'T make it required 2)That will make a filter called "Content In Queue" be available for you to add 3) Set that filter to "No" And that's it any entities that are in the queue won't come out in that view now


1

One of the options is to extend the IPE controller to remove the unwanted blocks from display. Here are the code changes: Route subscriber: mymodule.route_subscriber: class: Drupal\mymodule\Routing\RouteSubscriber tags: - { name: 'event_subscriber' } Update the IPE controller: <?php namespace Drupal\mymodule\Routing; use Drupal\Core\...


-1

i did this $nids = $query ->addMetaData('account', user_load(1)) ->execute(); and it fetched the value as an admin.


0

You can use hook_preprocess_html(). For example, to remove the system navigation block from the "sidebar_first" region, define the following hook in your MODULE.module: function MODULE_preprocess_html(&$variables) { if($variables['page']['REGION']['BLOCK']) $variables['page']['REGION']['BLOCK']['#access'] = FALSE; } with REGION = sidebar_first ...


1

You can create a custom block: https://www.drupal.org/docs/8/creating-custom-modules/creating-custom-blocks/create-a-custom-block In the build() method, you can return the form: public function build() { return \Drupal::formBuilder()->getForm('Drupal\system\Form\ThemeSettingsForm'); }


2

BlockBase implements BlockPluginInterface, which defines blockForm() as follows: public function blockForm($form, FormStateInterface $form_state); Interfaces are like contracts. Any class that implements an interface (or one of it's descendants) must define all the functions in the interface, and they must be defined exactly as in the interface. This is so ...


2

There might be hundreds of ways to add this markup in Drupal. The two simplest that came to my mind are: 1) Add a suffix to the form tag in form build or form alter: $form['#suffix'] = '<div>Suffix to form</div>'; 2) or add the markup in a form.html.twig below the form tag: {# /** * @file * Default theme implementation for a 'form' element. ...


0

Block-plugins that inherit from BlockBase can have their context values directly set via ContextAwarePluginBase::setContextValue($key, $value). This method can be used by a preprocess function to inject context that isn't otherwise available from the route or environment. In my case I have a block that needs a group entity in its context: <?php ...


2

You find the block_content entity in the template variable elements to get the ID: block.html.twig: {{ elements.content['#block_content'].id() }}


0

My teammate figured this out: {{ content['dynamic_token_field:block_content-link_card_edit_block'] }}


0

I'd do it like this. Example below is used for node templates: use \Drupal\views\Views; function MYTHEME_preprocess_node(&$variables) { // make the result count available as a variable for a certain content type if($node->getType() == 'news') { $view = Views::getView('related_news'); $view->setDisplay('default'); // contextual ...


Top 50 recent answers are included