Questions tagged [8]

Version tags should be used only for questions that apply to a version only, not to merely say what version a site is using.

Filter by
Sorted by
Tagged with
0
votes
2answers
68 views

Print a view inside a block

In Drupal 7, I use the following code to print more than one view inside a block. <?php print views_embed_view('view_name', 'display_name'); ?> In Drupal 8, it doesn't work and it returns ...
0
votes
1answer
91 views

Drush: How do I change the Drupal root

My Drush commands doesn't work because my Drupal files are in another directory than the one set in Drush. Everything is set up to this path so I can't just change the folder name. Drush status [..]...
0
votes
1answer
133 views

How do I dynamically change cookie_lifetime?

I'm trying to change cookie_lifetime dynamically in my D8 project, to set cookie_lifetime to 0 or to some value(for example 24 hours). I know that this can be partially acomplished by changing ...
0
votes
0answers
30 views

How can I limit views results based on the value of two fields?

I may have to do this programmatically, but I was wondering if there's another way in the UI. Basically, I have a list of articles with Volume and Issue fields. I want the view to only show articles ...
0
votes
1answer
480 views

Block in Drupal 8

I have coded a plugin in my module which extends block base and generates labels for block in /admin/structure/block page under Place block. These block are being generated for different entities. The ...
0
votes
1answer
585 views

All instances of block are not getting removed

This question is a continuation of this Block in Drupal 8, The second problem I am facing is that suppose I select block made for comment section and place it under Sidebar second section and ...
0
votes
1answer
313 views

Injecting additional content from multiple sources into a block using twig

I have a module which presents a table of contents from a twig template of examples on to how to use the module. This listing is located at /flot-examples. I would like additional modules to be able ...
0
votes
1answer
84 views

Link field is removing query parameters

We have an Article that a link field, field_link. When we create a new page of type Article, we set the link field to have a URL of www.example.com/somepath?someid=123345 and label of View. When the ...
0
votes
1answer
35 views

Can I connect via REST services with a mobile app I will develop?

I'm thinking of developing an e-commerce with Drupal 8 and Drupal Commerce, but I need to know if I can connect via REST services with a mobile app that I would develop too. The app would need to be ...
0
votes
1answer
277 views

How to display node details and call function in *.html.twig

I work in D8, I create a custom module first_module. By modules create a url and display all nodes by *.html.twig file. Write code in controller.php public function contentthree() { $connection = ...
0
votes
1answer
145 views

Create migration stubs of entities for a multiple value reference field?

I need to import a set of authors as part of a content entity. It is an array in a JSON object of id/name. I have a field in Drupal on the content type to be a user reference that accepts unlimited ...
0
votes
1answer
57 views

Can You Render Data from Forced Fields in Views While Using format “Show: Content”

Drupal 8.x Is it possible to render fields in a view when the display format setting is set to format "Show: Content" ? For my case, the contrib module I am using has some views integration that ...
0
votes
1answer
79 views

Sort view by tag count

I have to show all the tags and sort based on count. I am able to get the count of tag used by pages through views but not able sort based on count as this option is not available in views. Any ...
0
votes
2answers
435 views

How to create search indexes by path in Drupal 8?

For a relatively small Drupal 8 website, I need to enable a search box, with multiple indexes based on the path or menu value. For example; the main menu has 2 menu items linking to basic pages: ...
0
votes
1answer
281 views

Validation constraints on form fields ignored

Trying to figure out custom validation with constraints, but no luck yet. Right now, my form posts content and gives no errors when form is filled out incorrectly. (Please avoid suggesting ...
0
votes
1answer
549 views

Create new child field collection programmatically

I have 2 field collections (Parent and child) Parent Field collection: Test Student Info machine name: field_test_student_info Child Field collection: Marks machine name: field_marks In parent field ...
0
votes
0answers
35 views

Entity Reference View fails after update to drupal 8.7.6

Recently I updated my drupal site from 8.6.14 to 8.7.6. A previously-working Entity Reference View display that is connected to a form Autocomplete field stopped working. The spinning circle keeps ...
0
votes
1answer
286 views

Dynamically creating menu items

What I need is to add menu item to some menu, but it should have different parameters (title and url) depending on language. So I created new module and added links.menu.yml like: my_menu_item_id: ...
0
votes
1answer
93 views

Print custom product variation field in order email confirmation

Added custom field ('field_secretkey') under Commerce - Product variation (admin/commerce/config/product-variation-types). I am able to get this value in Orders view by adding the "Product variation"...
0
votes
1answer
53 views

Enable translation for theme settings

Theme settings are not translatable in core. Is there a way to make them translatable? I have some additional theme settings which needs to have different values per language. I'm trying to achieve ...
0
votes
1answer
260 views

Copy installed modules and configuration to new installation

I have a Drupal 8 application with mysql as database. I installed bunch of third part modules such as domain, search_api, pdf etc... Most I installed using composer and a very few using "Install ...
0
votes
1answer
376 views

Programatically change autocomplete views exposed filter by a select list

I have a view which has a filter by users that created de nodes. This filter is exposed, in order to select an user and filter the results by this user. I would like to change the default autocomplete ...
0
votes
0answers
946 views

Quick edit with custom twig templates

I am trying to get quick edit to work in combination with my twig templates where i only print out specific fields like this: {{content.field_teaser_overline}} The rendered markup of the field looks ...
0
votes
1answer
175 views

Modifying argument of programmatically called render service. (e.g.: theme to use) = Get object from service container with modified argument

I use the D8 core render service for generating markup that is indexed in an external search service. The indexing is happening on hook_entity_update, where I call my indexing service. My custom ...
0
votes
2answers
2k views

RedirectResponse not able to redirect in hook_entity_view drupal 8

I am trying to redirect users to a page on entity view. I am using RedirectResponse in hook_entity_view. But it is not redirecting to the desired page. This is how I implemented this. After fetching ...
0
votes
1answer
125 views

Clean way to programmatically add attributes to a view field entity label link

I have a View that lists entities. One of the fields is the entity label field, which is set to output a link to the entity itself. I would like to add attributes to the <a> tag to grab later ...
0
votes
2answers
59 views

How to get the part of URI and pass it to as a argument?

I can access current path using method \Drupal::request()->getRequestUri(); as shown below. function bartik_preprocess_node(&$variables) { $variables['current_path'] = \Drupal::...
0
votes
1answer
2k views

Clone a node programmatically

I am modifying the node content on hook_form_alter() as follows. $node = \Drupal\node\Entity\Node::load($nid); if ($node) { $node->field_p_frontip = $availableip[0]; $node->save(); ...
0
votes
1answer
932 views

What can break quickedit, and how do I fix it?

We hired someone else to make our theme, and they gave us something with the quickedit not working. What can cause this to break, and how do I fix it? Here's what my contextual-links ul looks like ...
0
votes
1answer
309 views

How to retrieve value of hidden field in twig?

How to retrieve value of hidden field in twig? PFB screenshot: I am able to retrieve value of "Partition Count" field when not disabled. But not able to retrieve it's value when disabled. Exact ...
0
votes
1answer
56 views

View of blog posts grouped by year

Client wants a blog archive with the posts inside accordions whose toggle is the year. Two example years HTML below. I have the individual fields exposed as tokens within my view with no problem. ...
0
votes
1answer
48 views

How to Inject entity object in EntityForm

We are trying to recreate https://www.drupal.org/project/menu_editor for Drupal 8. So our idea is to extend MenuForm and then override the form in our own way to achieve what menu_editor for Drupal 7 ...
0
votes
2answers
618 views

Fetch fields of a block defined via content type programmatically

I've created a block type via the UI. This is a translatable block with 3 text-fields. I am using hook_block_view_alter($build, $block) to massage the data. However, I can not seem to find the fields ...
0
votes
1answer
63 views

how to extend FormBuilder::processForm from multiple API endpoints in one class

I'm trying to consolidate my form processing by entity_type, without rebuilding the forms (just using the default forms provided by Drupal. I have dynamic routes pointing to a _controller::method. I'...
0
votes
0answers
20 views

Migration paths for Webforms or Contact Storage modules

Were there ever existed, or is there an existing tradition to create migration paths for Webforms or Contact Storage modules? I ask this because on the one hand I'm not a PHP programmer and on the ...
0
votes
1answer
2k views

How to pass a custom Form to a Twig template

my problem is that my drupal 8 form is not getting rendered in twig template. I created a form with build form method in drupal 8 when i tried it to pass in twig template it is not getting passed.for ...
0
votes
1answer
166 views

How to check if an article is referenced from a collection?

I have a collection content type which is just a list of EntityReferences to articles. When I am loading an article, how can I use the Entity API to check if it belongs to one or more collections? ...
0
votes
1answer
1k views

Dynamic dependent form select inputs

I'm building a custom dependent dropdown form with 2 select inputs. I've managed to build the form inputs and update them accordingly, but I'm not able to get the dependent select's value in the ...
0
votes
2answers
2k views

How to get node url from Entity Reference field?

We have an ECK Bundle that has an Entity Reference to Article and Basic Page content type. In the twig template we are using the following line below to get the node's nid value and then using that in ...
0
votes
1answer
158 views

Where is the “add to cart” configuration?

I'm trying to find the Add to cart form configuration for a product type in the UI. When I export configuration, core.entity_form_display.commerce_order_item.TYPE.add_to_cart.yml contains the ...
0
votes
1answer
2k views

Ajax Form submit doesn't work second time

I'm loading the node/edit form in a block and I add ajax on submit. I add the Ajax in the hook_form_alter. $form['#prefix'] = '<div id="' . $form_wrapper . '">'; $form['#suffix'] = '</div&...
0
votes
1answer
189 views

Complex Filter Criteria no Results

I'm working on a views to show different events in a calendar. I want to be able to filter on terms (In my view the field is called 'Wat?' for terms like music, art, design, etc). For this I create a ...
0
votes
1answer
85 views

How do I show the members in a block, contextually filtered by the currently logged in user?

In my project every group member will only ever belong to a group; some group members have the Group Administrator role. I would like to create a view block to satisfy this story: As a user with the ...
0
votes
1answer
81 views

How to get correct language code during installation?

I am programmatically creating some content during installation of my profile and I need to set the language for this content, otherwise it will be in English(which my site is not) and there will be ...
0
votes
1answer
68 views

Why do I get this error when I save my custom field?

I created a custom field and this is its formElement() method. public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { ...
0
votes
1answer
217 views

Making entities under another entitytype

Suppose, I've created -name -machine_name an entity_type myentity with its schema as: -name -machine_name Next, I want to create another entity subentity that will be grouped under myentity. ...
0
votes
2answers
188 views

Restrict creation of new taxonomy terms via node form through entity reference filed (autocomplete) for particular user role

I have Entity reference field (taxonomy terms ) in node form. I have checked the option (Create referenced entities if they don't already exist) so that users can create new taxonomy terms in field ...
0
votes
2answers
947 views

How to get the string value from the function CountryManager::getStandardList()?

Input : $li = array(); $list = \Drupal\Core\Locale\CountryManager::getStandardList(); foreach($list as $key => $value){ $li[$key] = $value; } // print_r($li); Output : ...
0
votes
1answer
198 views

Drupal 8 reset session each request [closed]

I have create a EventSubscriber like this: <?php namespace Drupal\custom_session\EventSubscriber; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\...
0
votes
2answers
256 views

Creating a dynamic menu

I'd like to make a Drupal 8 menu dynamic so it can i.e. point to the latest node of the articles or news or hide another from the menu if it doesn't have an entry at all. How can I achieve this?