5

you can also use something like the following, it all depends of the type of object you are extracting and the field name, In my case it was a paragraph with a field named field_link and the following worked: {{ paragraph.field_link.get(0).getUrl().toString() }}


4

I can code a little but I'm not very good so I'm having trouble finding an approach to implement this. I started 7 years ago from zero, I only knew HTML and CSS. I learned and mastered Rules & Views. But like 4 or 5 years ago, I ran into scenarios like this one where the existing modules didn't quite do what I needed or felt I had to do overkill/bulky-...


3

Found a way to satisfy all the cases without having to create multiple blocks (visibility rules would be odd) or create different menus. I could not achieve this by assuming a content type like in the question, because you could have the same content type nested until multiple areas of the menu, and not really know if the current depth you were at for it ...


3

It looks like a proper fix for this has been added to the latest version of core, 8.8+, see #2863188 Hardcoded result size limit in the entity reference autocomplete widget.


2

That is not the default behavior. I suppose you have installed Menu Block module. In that case the "expand all" option from Drupal Core does not seem to work, you will need to use the "expand all" option from the Menu Block module. You can find this at "Advanced options" in the block configuration.


2

In a custom module, create a file called mymodule.links.menu.yml. Inside this file, add the following: view.abc_links.page_1: #your view route title: 'ABC Link' route_name: view.abc_links.page_1 #your view route description: 'ABC Description' mymodule.admin.structure.settings: title: 'API Link' description: 'ABC Description' route_name: view....


2

You can go to /admin/structure/menu/manage/admin and add this link.


2

/** * Implements hook_toolbar(). */ function backlinks_notifications_toolbar() { $items = []; $items['toolbar_menu_backlinks_notifications'] = [ '#type' => 'toolbar_item', 'tab' => [ '#type' => 'link', '#title' => 'Notifications', '#url' => Url:...


2

The _node_operation_route option respect the Use the administration theme when editing or creating content, if you want to explicitly disable admin theme for this node-related page don't use _node_operation_route The _node_operation_route option overrides _admin_route https://api.drupal.org/api/drupal/core%21modules%21node%21src%21EventSubscriber%...


2

The reason these tabs show up on all of your content types is that entity.node.canonical is the base route for all nodes. Since you're setting entity.node.canonical as the parent_id, Drupal thinks you want these tabs displayed on every node page. The easiest way to achieve your goal is probably to implement hook_menu_local_tasks_alter() with code similar to ...


1

Not exactly. You could theoretically build non-config menus with a custom module, but I don't think that's what you want to do. You can, however, get keep the menus as config, but keep them from being exported / imported. You can use two contrib modules to do this. The first module, Config ignore is required. This module allows to set config files that ...


1

You're doing a switch(), but with only a default for the switch and no options, it means the switch is unnecessary. Drupal also provides the drupal_goto() function, which handles both redirects, as well as cancelling killing the script so the redirect can proceed. Your code can be simplified to: function my_customerror_page($code) { $dest = variable_get('...


1

Add a derivative for each language: /mymodule/src/Plugin/Derivative/TranslatedNodeTabDeriver.php <?php namespace Drupal\mymodule\Plugin\Derivative; use Drupal\Component\Plugin\Derivative\DeriverBase; use Drupal\Core\StringTranslation\StringTranslationTrait; class TranslatedNodeTabDeriver extends DeriverBase { use StringTranslationTrait; /** *...


1

No, not by itself. The Token Filter module's functionality adds a token input filter to text formats in Drupal. The only field types that can use text formats are the 3 Text (formatted) field types, not the Link field type. One can only speculate on the comment's solution you refer to. Text Formats/Input filters are designed to allow HTML input that should ...


1

The documentation is inevitably focused on PHP, since Drupal is written in PHP and server-side renders. And the answer to getting info from PHP/server side to JS/client side is not really Drupal specific. Like any other situation of this ilk in web development, you have two basic choices. Either annotate your HTML with enough elements, IDs and classes ...


1

Views breadcrumbs can be tricky. You can create a module and a class that implements BreadcrumbBuilderInterface and do: class MyBreadcrumbBuilder implements BreadcrumbBuilderInterface { use StringTranslationTrait; /** * The AdminContext service. * * @var \Drupal\Core\Routing\AdminContext */ protected $adminContext; /** * The ...


1

In this case you should edit the template. Changes to markup should be done in templates. Ok thank you. I will extend the twig file. But just to know. How do I add it within my preprocess function? Looking into the standard menu.html.twig there isn't any place left to preprocess content to have it prefixed with some markup for example. There are just ...


1

I don't see anything obviously wrong in your code, but it would have been a better idea to post the 2 full examples (and ideally, you should try first a simple example that can be imported without custom plugins) Note that for the second YML file (the translation) you don't need to import most of the stuff: you basically need to process the id, the parent, ...


1

To set if the node has menu link you can use menu_ui_get_menu_link_defaults function from menu_ui.module something like: /** * Implements hook_preprocess_HOOK(). */ function YOUMODULE_preprocess_page(&$vars) { /** @var \Drupal\node\Entity\Node $node */ if ($node = \Drupal::routeMatch()->getParameter('node')) { // Get the default menu link. ...


1

Looks like that styling is being driven by the flex display on div.region-we-mega-menu. Creating a style that overrides justify-content: flex-start; to justify-content: flex-end; should do the trick.


1

I can recommend you Menu Link Weight together with Client-side hierarchical select. The combination of those two modules allow you to separate each level in an own select field and makes sorting pages within a level very handy. After installing both of them visit /admin/config/user-interface/menu-link-weight and select "Client-Side hierarchical select". ...


1

I know it's horrible, but if nothing else works: {{ link|replace({'internal:':''}) }} My situation: accessing a Link field via an overridden views template: views-view-fields.html.twig I had to get the variable from: row._entity.field_machine_name.value.0.uri (I gave up trying to use the fields variable, you can seemingly get a .content property out of ...


1

In paragraph, to get the link url and link name - <a href="{{ content.FIELD_LINK_NAME[0]['#url']|render }}"> {{ content.FIELD_LINK_NAME[0]['#title']|render }} </a>


1

Use macro instead, that's better for recursive twig


1

This is what I ended up using. use Drupal\menu_link_content\Entity\MenuLinkContent; \Drupal::entityTypeManager() ->getStorage('menu') ->create([ 'id' => 'test-menu', 'label' => 'Test menu', 'description' => 'Description text.', ]) ->save(); $menu_link_1 = MenuLinkContent::create([ 'title' => 'Link 1', 'link' =&...


1

For Drupal 8 you can create a link programmatically using Link::fromTextAndUrl not linkable like that: $my_link = Link::fromTextAndUrl(t('This is my link text'), Url::fromUri('route:<nolink>')); Optionally you can convert it to an array using: $my_link = $my_link->toRenderable();


1

To expand on @skorzh answer and reply to the comment from @Matt, if you want to nest a menu item inside another you have to get the parent id and set it as 'parent'. As an example this code nests the item inside the top level using the variable $top_level below. $my_menu = \Drupal::entityTypeManager()->getStorage('menu_link_content') ->...


1

My experience with Drupal 8 step by step First of all, you need to install Menu Export module and activate it. After that, you will have Export Menu in the Structure part. Steps to Export & Import 1- In the Export Menu page domain.com/admin/config/development/menu_export, you have three option, at Menu list select which menus you want to export. 2- On ...


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