Questions tagged [drupal-8]

Drupal 8 is the Drupal version that was officially released on November 19, 2015. Rather than using this tag, consider posting your question directly on https://drupal.stackexchange.com/.

Drupal 8 introduces major changes, such as the support for HTML 5, better support for web services, multi-language support, mobile devices, and a configuration API.

Use this tag only if your question relates specifically to this version.

Requirements

  • Web server: Apache, Nginx, or Microsoft IIS
  • Database server: MySQL 5.5.3/MariaDB 5.5.20/Percona Server 5.5.8 or higher with PDO and an InnoDB-compatible primary storage engine, PostgreSQL 9.1.2 or higher with PDO, SQLite 3.6.8 or higher
  • PHP: PHP 5.5.9 or higher

Related tags:

Resources

2837 questions
12
votes
4 answers

How to create an entity reference field in Drupal 8 programmatically?

I want to create an entity reference field in Drupal 8 using my custom module. Like when someone clicks a link on a Drupal page, an entity reference field would be created in the page node type automatically. Can anyone help me with this?
Ghan Shyam
  • 626
  • 1
  • 6
  • 18
11
votes
2 answers

Error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY'

Currently I'm getting this kind of message and I don't know how to fix it. The command php -m tells me that PDO and pdo_mysql are there. I'm using Drupal-8 with php7.1.20 on Ubuntu 18.04.1 LTS [Tue Sep 04 09:27:48.210064 2018] [php7:notice] [pid…
Mayari
  • 510
  • 1
  • 3
  • 16
11
votes
4 answers

Custom 404 template file in Drupal 8

How can I create a custom 404 page in Drupal 8? I have created a new page(Content) in the backoffice called 404 (node number 100). I have set it as the 404 default page at Configuration > Basic site settings. It works with the content that I have…
cadev
  • 123
  • 1
  • 2
  • 9
11
votes
6 answers

drupal 8 get taxonomy term value in node

Drupal\node\Entity\Node Object ( [in_preview] => [values:protected] => Array ( [vid] => Array ( [x-default] => 1 ) [langcode] => Array ( …
user32012
  • 129
  • 1
  • 1
  • 5
11
votes
3 answers

How do I get the parent tid of a taxonomy term in Drupal 8

I used the following to get the parent of a taxonomy term in drupal 8: $parent = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadParents($termId); $parent = reset($parent); Now that I have the parent how do I get the parent tid from…
William A Hopkins
  • 113
  • 1
  • 1
  • 6
11
votes
7 answers

How to programmatically get content type name in Drupal 8

I'm working on Drupal 8. And I want to get content type machine name and label. Here is my code: $cont_type = node_type_get_types(); foreach ($cont_type as $key => $value) { $label = $value->name; $machine_name = $key; } Here I got an error…
Rahul Seth
  • 415
  • 1
  • 5
  • 14
10
votes
0 answers

IEF reference show parent field as title using Auto Entity Label

I am new to Drupal 8 want to add a field value to IEF reference title. for now I am using Auto Entity Label version 2.x-dev to automatically generate title for my Entities but when it comes to IEF references I wan to get name of parent as title of…
Martin
  • 429
  • 3
  • 18
10
votes
6 answers

Accessing individual fields in Drupal 8 views templates

I'm having trouble doing something that I think should be relatively simple drupal 8 views. I have a content type called Countries. I would like to display the 3 latest country nodes on my homepage in a views block. Each country is displayed with…
Kaizen9001
  • 510
  • 1
  • 4
  • 11
10
votes
8 answers

Get URL parameters inside custom module

I've created a custom block like this: class HelloBlock extends BlockBase implements BlockPluginInterface{ /** * {@inheritdoc} */ public function build() { $config = $this->getConfiguration(); $result = db_query('SELECT * FROM…
zied123456
  • 255
  • 1
  • 4
  • 17
9
votes
5 answers

How to import / export content type in drupal 8?

How to import / export content type with their related contents from one website to another website in drupal 8?
user3178593
  • 113
  • 1
  • 1
  • 4
9
votes
1 answer

Drupal 8 Passing Custom Variables to Theme Template

So I have a controller with a route already configured my action looks like this /** * List of brands * * @return array */ public function listAction() { $brandIds = \Drupal::entityQuery('node') ->condition('type', 'brand') …
Matthew A Thomas
  • 924
  • 7
  • 15
9
votes
3 answers

Drupal 8 Twig isn't working for Debug

I have been messing around with Drupal 8 and seen that in the status report it suggested I should add the Twig C Extension, after adding it I begun to get the following error when using Kint in a theme template file. Warning:…
jafacakes2011
  • 188
  • 2
  • 6
9
votes
4 answers

Drupal 8, get programmatically the list of fields of a custom content

I want create programmatically a custom content (custom content created via the admin UI). But, before the creation, I want check programmatically the types of fields of my custom content My custom content contains a field "body" (type text), a…
spacecodeur
  • 2,206
  • 7
  • 35
  • 71
8
votes
5 answers

What version of Drupal should I choose?

Today is the first time I entered Drupal website in order to get my head around it and was met by API pages for versions 6, 7, 8. I think 8 is in production, but anyway - what is the best version to use at the moment?
jayarjo
  • 16,124
  • 24
  • 94
  • 138
8
votes
2 answers

Drupal 8 orphan paragraphs

I've noticed that Paragraph entities are not deleted from the database. They rather unlink from the parent node. This is noticeable if you create a view, that lists Paragraphs and attach a contextual filter, that filters by Parent ID. For now, I've…
Elaman
  • 851
  • 1
  • 10
  • 22