Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

11
votes
5answers
14k views

How can I prevent a particular page being cached?

I have activated the cache on my Drupal 8 site, and of course all pages are cached as expected. However, I'd like to have a specific page bypass that cache. In my controller I built the page as ...
0
votes
2answers
716 views

Form alteration is not working from within my form class

I am following https://www.drupal.org/docs/8/api/form-api/introduction-to-form-api for my hello world module. Below is my code namespace Drupal\hello_world\Form; use Drupal\Core\Form\FormBase; use ...
1
vote
1answer
342 views

How to get an instance of a plugin

I am attempting to use a pre-configured instance of a plugin. The plugin is of type @CommercePaymentGateway. I am currently trying to use something like: /** @var PaymentGatewayManager $manager */...
2
votes
1answer
350 views

Overriding system.site.uuid with an environment variable

I have a need to have separate sites behave as if they are clones of each other; that is, they each need to have the same site UUID. Due to the environment I am operating in, I am unable to change ...
-5
votes
0answers
33 views

Suggestion - Caching based on user

In my application a part of the header changes based on user to user. I have created a REST API service to collect the JSON data that builds the header based on that. I just want a suggestion whether ...
2
votes
1answer
562 views

CSS still requiring clearing cache after following steps to switch caching off

I have followed the steps detailed in this tutorial and many others -> https://knackforge.com/blog/rajamohamed/disable-drupal-8-cache-during-development I have copied and renamed the sites/example....
0
votes
2answers
353 views

How to get the distinct number of the nodes?

In my task I need to get the distinct number of the nodes of some content type. How can I do it? $query = $this->connection->select('node', 'node')->condition('node.type', $type); $query-&...
0
votes
0answers
8 views

Missing is empty operator on custom entity views integration

I have a custom entity called measurement. There is a baseFieldDefinition field called completed. When I am creating a view for this custom entity, I want to add a filter to the view so that only ...
0
votes
1answer
409 views

Views block template print individual field from content

I created a view of paragraphs and I passed the parent ID as the contextual filter using a relationship to the content that use the field that reference the paragraph. I can see the data been ...
2
votes
2answers
33 views

Get author id in field template - or make an edit button on a node's teaser

I am using Display Suite to display Teasers of a custom content type Project in a View. I want to show link on each Teaser to edit that node if the logged in user is the author of the node. Our ...
0
votes
0answers
11 views

Entity print module. How to create TOC?

I'm using entity print module and wkhtmltopdf library. Even though I've checked the create table of contents on the configuration, I don't know how to do that. I've created h1, h2 and h3 but the TOC ...
0
votes
1answer
38 views

How to make get for drupal behaviors to run only once?

Drupal.behaviors.js_mod = { attach: function (context, settings) { //$('body', context).append(chart); // $( '#drupal-myradar', context ).once $.get( "/web/js/mod", function( data ) { ...
0
votes
0answers
19 views

Check if a user has already created a node and redirect the user when the node exists

I am trying to redirect users to a page when they have already created a node in mytheme.theme, in order to prevent a user to create a node twice. function mytheme_node_prepare($node) { if ($node-&...
-1
votes
0answers
18 views

How to change the value of data-drupal-selector?

I am using the Bootstrap 3 theme for Drupal 8: https://www.drupal.org/project/bootstrap I would like to change the value of data-drupal-selector generated by the twig /bootstrap/templates/system/...
0
votes
0answers
13 views

Prefilter facet using URL

We have added facet_categories to our Articles page which is a view page with the path url of /articles. Facet_categories is setup to be the Articles->Category field (which is a taxonomy term). ...
5
votes
1answer
810 views

Drupal 8: When I POST an image file via rest, response is 201: Object Moved, status is temporary

I'm attempting to POST images to Drupal 8 via the REST api. The creation is successful (201) and the images appear in the files list. However, there are problems. I'm not sure if they are ...
0
votes
0answers
60 views

Loading a view page is very slow

On Drupal 8.7.3 and a very powerful VPS server with php 7.2, I have a view (page) that will list all available nodes of a specific content type. The display of the view is "Footable" taken from the ...
0
votes
0answers
27 views

How to add a token with the flag to the Message module?

I have a site on Drupal 8 with the Message, Flag and Token modules. I created a custom module to create a message when an entity is created on the site. I also created a flag to mark messages as ...
0
votes
1answer
565 views

The directory public://xmlsitemap was not found or is not writable by the server

I have just installed XML Sitemap on a EC2 drupal 8 instance. I am seeing the following error message in the admin report status page: XML sitemap cache directory Not found or not writable The ...
0
votes
1answer
29 views

Content entity doesn't load on edit

I have a custom entity, BaseEstablishment which is an abstract base class, implemented by Practice. abstract class BaseEstablishment extends ContentEntityBase implements EntityOwnerInterface { // ...
0
votes
1answer
216 views

How to inject a new variable into a menu template

I have a menu with a machine name of menu-principal, which in turn has a theme hook of menu__menu_principal and a template of menu--menu-principal.html.twig. I'm trying to inject another menu into the ...
0
votes
1answer
346 views

Change view format programmatically in Drupal 8

How to change view format progammtically using "hook_views_pre_render" in Drupal 8 or some another method ?
0
votes
0answers
22 views

Services: Updating file/image on server

I'm able do retrieve, delete an image from Drupal server using services https://example.com/entity/file/[fid] But I couldn't able to do the same for updating. I tried like follows to update the ...
-3
votes
1answer
87 views

Use a Twig filter to resize / crop images in templates [closed]

I want to use a twig filter to resize/crop images in Drupal 8 templates for responsive images, I know I can generate responsive images with Image Style and Responsive Image styles, but that requires ...
0
votes
0answers
22 views

How do I update the progress indicator?

Does anyone here know how to update the progress indicator in Drupal 8? I've done this in Drupal 7 many times with code similar to here (using URL & interval) http://api.drupal.org/api/drupal/...
0
votes
1answer
597 views

Allow special characters in the Search Form

I can't search with any special character in the default search block form or in search API. Commonly used word like B&W (black and white) don't seem indexed up well, probably due to some encoding ...
-1
votes
0answers
22 views

How to add Global PHP field in Drupal 8 views? [closed]

I want to add a Global PHP field in Drupal 8 views to add custom PHP field. How can I add this? Any module is available for above scenario?
1
vote
1answer
280 views

Json api create comments

I am using the JSON API module and I would like to create a comment. I was able to create nodes based on the documentation found here, but I can't figure out how to create comments. How can I add a ...
26
votes
11answers
53k views

“The website encountered an unexpected error. Please try again later.”

I have this error with Drupal 7 how can I have some more information about this error ? Any report, any log anywhere ? Nothing in php errors. how can I disable that message and have a more useful ...
3
votes
1answer
993 views

Related content in a view using entity reference

I've browsed through (and tested) every solution I could find here to this seemingly simple challenge. I've got multiple content types (fx. News, Releases, Events, Videos etc.) that are referencing ...
1
vote
1answer
36 views

Field collection item code not working

Hi Every one I am trying to create new field collection item programmatically but code is not working. I want to create a number of field collection items but no Luck. My code is following. use ...
0
votes
0answers
30 views

Error when adding a custom field

I created a module for custom field but when I activated it I no longer had access to the field add page. Fortunately, @Kevin helped me see where the mistake was; thank you to him. Now I have access ...
2
votes
3answers
529 views

Is there a way to stop Order checkout in Commerce 2.x?

Is there a way to stop an Order checkout process in Commerce 2.x when a product is out of stock? Requirement: I have a product with quantity in stock available as zero A user/customer logs in ...
0
votes
1answer
972 views

Fatal error: Cannot declare class error for custom migrate process

Not sure whats happening here, but I'm defining a custom migrate process plugin and I'm getting the error Fatal error: Cannot declare class StrReplace, because the name is already in use, even though ...
14
votes
4answers
11k views

Check if the user is logged-in in a theme

In Drupal 7 we can simply check if the current user is logged-in in a theme by checking $GLOBAL['user']->uid or using user_is_logged_in(). How can I check if a user is logged-in in a page ...
0
votes
2answers
1k views

How to change taxonomy url in node view page?

How to change taxonomy url in node view page in Drupal 8? In node view page I am getting taxonomy term url pattern as term/{%term_id}. I want to change taxonomy term url to custom url in Drupal 8. ...
0
votes
1answer
22 views

How can I render an HTML table in a block?

i have created a module for showing third party API data here is some data returned from that API {"ObjectId":43,"ObjectName":"MEGA MELA","ObjectTitle":"Event Created by API","ObjectDescription":"...
0
votes
1answer
30 views

How can I purge a specific URL from varnish cache without making a curl request?

I'm programmatically updating images and keeping the same file name. I flush the image styles for the image when I do this, but I'm running into an issue where my image styles aren't being regenerated ...
0
votes
1answer
24 views

How to add unique class to each checkbox elements

I am displaying checkboxes using form API in Drupal 8. For functional and theming purpose I need to add unique custom class to each checkbox element. Is there any way to add classes to each checkbox ...
7
votes
7answers
4k views

How to import taxonomy with hierarchy?

We're upgrading our site from D7 to D8, which has vocabulary containing multi-level parent-child hierarchy. The list is too long (around 5K-10K terms) to import manually. We've tried using migrate in ...
1
vote
1answer
27 views

How to filter Views records by day-of-week, including multiples

I have a need to filter many records by the day of the week derived from a date-only field in those records (i.e. not today's dow). I would like a solution that works with views filters, as the wider ...
-1
votes
1answer
34 views

How to Restrict some special character in password field

I'm very new in Drupal, I would like to restrict some special characters from user password field Is there any way to edit configuration of core modules i'm trying to create preg_match modules . i ...
0
votes
2answers
657 views

Setup custom required field validation for a field in custom form

How can I setup custom required field validation message for a text field in my custom form. I tried below code. But it is not working. It always showing 'Please fill out this field'. $form['...
0
votes
0answers
12 views

Setting default value to custom fields in menu items

I created a custom boolean field in my menu item using this hook_entity_base_field_info function Mymodule_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) { if ($...
-1
votes
0answers
14 views

Custom entity won't install [closed]

I generate a custom entity for custom module with drupal generate:entity:content. When I run drush updatedb --entity-updates, it doesn't anything, on the database. Something to edit before to register ...
0
votes
0answers
74 views

Adding jQuery to a webform

Trying to count selected radios in a webform, I managed to make it work outside drupal (please see link below) but I'm not sure how to add it to my theme/webform. https://jsfiddle.net/j9q75Lay/ I ...
0
votes
0answers
40 views

Error: Cron has not run recently. But it did!

I have a site (hosted on Acquia) which always return an error about cron not running on the Status report page, but it actually runs regularly and it does all the task attached to it. Cron is running ...
8
votes
4answers
3k views

How do I migrate file entities into media entities?

I am using the Migrate module for a D7 to D8 migration and I am writing the whole migration manually in code (rather than use the built in D7 migrate module, as I wanted more granual control on the ...
1
vote
2answers
51 views

Fetch view results from mymodule_preprocess_page hook

We have a View page that is coming from myview. Using the header setting in the view we have added @total results already, which displays in the views-view--myview--page-1.html.twig using the {{ ...
0
votes
0answers
17 views

How to add an additional link into node links array programatically?

I would like to add a additional link into the links list of my node-type teaser-display (where "write a comment", "read more" link are located). Also I would like to pass some tokens (token module ...