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
0answers
30 views

Years missing in Views' exposed field

I have media content I want to add an option for viewers can view by year from select option. I have added Published on and then checked on exposed with year checkbox as you seen in snapshot but it ...
0
votes
0answers
20 views

How can I provide module translations?

in Drupal 8 we have added some elements and created some new modules. These elements and modules were labeled in english. As on the picture, red marked elements are still in english, the others are in ...
0
votes
1answer
28 views

Add content screens from the front end

I am building a web application (for trusted users), so the logged in user will have the ability to add content. However currently, when the user wants to add a record, they move from the frontend ...
4
votes
1answer
3k views

field_info_field() deprecated, what's the equivalent?

In Drupal 8 field_info_field() has been deprecated. The docs say to use this instead: Field::fieldInfo()->getField($field_name) I've tried various iterations of it, such as: $foo = \Drupal\field\...
3
votes
1answer
139 views

drupal_render() is deprecated. What replaces it?

I have a render array and I want to convert it to HTML and place it in a WYSIWYG field. What is the generally accepted way to do that since drupal_render() is deprecated?
0
votes
1answer
29 views

views_pre_render add class item to a row

When pre-rendering a view row is there a way to add an HTML class into a single row of the markup, allowing me to add a new background colour to the event item highlighting its importance? For ...
0
votes
0answers
30 views

How can I override image attributes for each row in a view?

I am currently trying to write a preprocess to change the img tag on 2 views but with no success using the below code: use Drupal\node\Entity\Node; function mytheme_preprocess_image(&$variables) ...
0
votes
1answer
30 views

How can I have a view to load more rows on clicking a “Load more” button?

We have created a view, myview, where we want to display 3 nodes (content type = basic) and add a View All button on page load. The purpose of the 'View All' button will be to show 6 more (the view is ...
2
votes
2answers
62 views

How can I exclude some entities in “drush entity:delete” command?

I want to delete all content of custom entity type except some specific items, I found drush entity:delete CUSTOM_TYPE command to delete all contents but couldn't exclude some items from deletion in ...
3
votes
2answers
712 views

How do I get JSON data from a custom entity

I would like to GET JSON data from drupal 8 custom entity. I am using ubuntu 14.04 and vagrant. For that i have done these steps. I have taken reference to Create drupal 8 custom entity from this ...
0
votes
0answers
17 views

Can't edit media Image from within node edit

I'm using Media and the Media Library (yes I know this is experimental). And all of the sudden I'm not able to edit my added image when I'm editing a node. In an earlier stage of the website I was ...
3
votes
3answers
5k views

$form_state->setValue() doesn't save value

I have an validate code: public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); $form_state->setValue('my_variable', $...
4
votes
2answers
5k views

How do I consume REST data with an external service?

I want to integrate RESTful API with drupal 8. What I want to achieve is my a project which is built in drupal 8 is the consumer and RESTful API is integrated into another website using CodeIgniter. ...
2
votes
3answers
904 views

How do I print the title in page.tpl.twig?

I am trying to display title and other fields in page.tpl.twig. {{ title }} doesn't display the title, but {{ page.content }} displays all the content. How do I print the title in page.tpl.twig?
1
vote
2answers
3k views

Pass variables from controller to existing node template file

In the Drupal 8 documentation I have found a way how to pass variable from controller to custom twig template https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-...
1
vote
1answer
21 views

Call to undefined function Drupal\Component\Utility\imagecreate()

I got this error on a server I setup and was confused: Error: Call to undefined function Drupal\Component\Utility\imagecreate() in Drupal\Component\Utility\Random->image() (line 282 of /var/lib/...
2
votes
1answer
1k views

Clean urls not working

I just have Drupal 7 and 8 installed in my localhost on Opensuse Leap. With Drupal 7 I cannot pass the clean urls test, however the site is completely functional. By clicking the links on the menu I ...
0
votes
0answers
12 views

Create Taxanomy Menu with specified starting term

D8 Taxonomy Menu module is perfect to create a dynamic menu for a given vocabulary. I would like to create a menu starting with a term or subterm. For example, Vocabulary VocabA 1 Term1 1.1 ...
0
votes
0answers
30 views

No AJAX when user is logged in?

I am developing an e-commerce site for one of our customers for the first time with drupal. It is going pretty good so far but there is a weird misbehavior where I have no idea on how to handle it in ...
0
votes
1answer
30 views

How to grant create and update permissions to a custom role?

I have a new role as "Publisher". I want to grant Publisher 'create' and 'update' permission using code. My .permissions.yml file looks like this : 'delete contact entity': title: Delete entity ...
2
votes
1answer
33 views

How to get fields from taxonomy terms?

I am able to retrieve taxonomy terms programmatically, (as long as I only want to reference the default fields, 'tid' and 'name'). But how do I access custom taxonomy fields? $vid = 'MACHINE_NAME'; $...
0
votes
0answers
15 views

search_api_solr adding boost/weight/importance to a taxonomy value

I have a Taxonomy referenced from entity reference fields on multiple Content Types. It's "version". So what version of the software relates to the content being read. Often, this content is nearly ...
0
votes
0answers
28 views

Default Paragraph Config Per Content Type

We're using a paragraph for the hero/header of our site. Within the paragraph are a number of different toggles to define various options for the hero. I'd like to have it so that if the user is ...
4
votes
2answers
1k views

How do I filter by node ID in views?

I am trying to add Node ID in contextual filters but it seems there isn't Node ID anymore.
1
vote
3answers
763 views

How to get Media image values (alt and title) in Views?

I want to edit the Media library module View to show the images Alt and Title field value, but it is not in the available fields (only "Thumbnail(alt)" which prints the image). All available ...
0
votes
0answers
57 views

Manual Update from Drupal 8.7.6 to 8.7.7 Acts Like New Install

I have been manually updating Drupal 8 core successfully until now. When I try to update from 8.7.6 to 8.7.7 it goes to a new install. Here is what I did Back up database, and back up entire site ...
1
vote
2answers
100 views

Add Fields to View page

I have a view that is a page and I'd like to be able to add a a field to this page. My other pages are content type pages and they have the option to assign a top hero banner content type to them. ...
0
votes
0answers
43 views

How can I trigger the EntityTypeEvents::UPDATE event?

I tried to trigger event on each entity update. This is my src/EventSubscriber/MySub.php use Drupal\Core\Entity\EntityTypeEvents; use Symfony\Component\EventDispatcher\...
0
votes
0answers
26 views

Redirect from a path

I have a routing.yml file with a path which triggers a controller method. When the controller method finishes the operation I want to return user to the page he came from originally. I don't want to ...
2
votes
1answer
76 views

How to add a theme preprocess function for published state?

I want to create a body class for the published state of a node. I found some suggestions below for Drupal 7, but this code is not working for my Drupal 8 theme. Add class based on published state ...
0
votes
0answers
36 views

How can I display a webform on a node?

I am trying to display my webform using MYTHEME.theme file but I did not get any result. I am using code below: function THEMENAME_preprocess_webform(&$vars) { $wfid = $vars["element"]["#...
0
votes
1answer
40 views

Setting a Twig to a specific Form Container

As the title says, There is a specific Form Container that I would like to add a twig to that is on a page having its own twig. No theme hook name suggestion is provided when I inspect its element. ...
0
votes
2answers
619 views

Webform Submission Using Rest API POST method

I just created the webform and added fields. I need to create a Webform Submission Using Rest API POST method. I just installed Rest & Rest UI modules for this. But when I try to test my API ...
0
votes
1answer
1k views

NotFoundHttpException after changing webiste hosting, sub-domain

After changing webiste hosting (Drupal 8) I got this very un-intuitive error message: The website encountered an unexpected error. Please try again later. Symfony\Component\HttpKernel\Exception\...
1
vote
1answer
473 views

Conf_path is deprecated but what is its replacement?

Im upgrading a D7 module to D8 and it turns out conf_path() is deprecated but I cant find the replacement. I found a github page that said use this DrupalKernel::findSitePath(Request::...
3
votes
1answer
127 views

applyUpdates() is deprecated. Is it really needed in hook_install() anyway?

I maintain a contrib module which defines two base fields, but these are not added to any content type on installation, as this is done during admin config. The module has // Add our base fields to ...
3
votes
2answers
2k views

User Locked out after 5 failed login attempts - how to help him?

I have a user with 5 failed login attempts...and now he's locked out. We reset his password...but is there something else we need to do to unlock his account on a basic Drupal 8 setup? I'd rather not ...
0
votes
2answers
624 views

Responsive background image in Twig template

I would like to render an image as background image in my Twig template. To optimize my resources I'd like to use a responsive image but I cannot find a way to use it for background images. For a ...
2
votes
1answer
2k views

How to rename uploaded files

Using Drupal 8, I want to rename and clean all filenames, e.g. If someone uploads file named like this Screen Shot 2016-03-29 at 1.13.21 PM.jpg, I want to clean it so that convert all spaces to dashes ...
1
vote
2answers
260 views

How can I make a response cachable by browsers?

I am working on a Drupal Controller implementation that would return a generated image as response. I used Symfony's Response and I was trying to add ETag header to it: use Drupal\Core\Controller\...
4
votes
3answers
1k views

Get title from Route

I am trying to print out a few links on a custom page template. I would like to use the title and url from each route. I am trying to print out the title from the route. I know I can get the url ...
0
votes
0answers
17 views

Search API boosting results how to

I followed the guide via this article: https://www.easternstandard.com/blog/2018/05/drupal-8-search-how-get-better-more-intuitive-search-results-using-search-api Search API is searching both content ...
1
vote
2answers
411 views

Why is my library not attached when programmatically rendering a block?

I have this block: public function build() { $build = [ '#attached' => [ 'library' => [ 'mymodule/mylibrary', ], ], '#markup' => '<!-- see template -->...
0
votes
1answer
414 views

Display price in add to cart form BEFORE add to cart button

the logical flow of choosing attributes is seeing price adjustments based on the attributes chosen before the buy button ... how can i display the price in the form itself so it appears BEFORE the add ...
0
votes
2answers
38 views

How can I create two blocks at once from the same custom module?

I have figured out how to create a block from a custom module, by creating a ./src/Plugin/Block folder, then creating a PHP script inside it, with the following code: <?php namespace Drupal\...
0
votes
2answers
43 views

Display the day of the week

I have a content type with various fields. One of these is a date field. After typing in the date I would like to display the day of the week to the right of the date.
0
votes
1answer
24 views

How do I need to configure my site on AWS with Elastic Load Balancing to force HTTPS everywhere? [closed]

my site is up and running, but all my form submits get redirected to an http:// link. The redirect from http to https on my Server (Apache on EC2) is configured and you don't see any effect as a user. ...
1
vote
1answer
417 views

Where is the “Send mail to all users” action?

I installed and configured the Rules module. When I try to add a rule like notifying a new comment to all users, I do not see the Send mail to all users action. Is that normal? Is there any other ...
3
votes
1answer
2k views

How do I programmatically remove a block?

I have a custom module that is intended to be deployed as a pure web view, with no styling whatsoever beyond what I created in the .twig file. I installed the Stark theme and in my local instance I ...
2
votes
2answers
410 views

How to display custom data array via Twig

I've created service which gets the raw data from custom content type. It looks like this : Array ( [front_page_slider] => Array ( [1] => Array ( ...