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.

1
vote
1answer
70 views

How are Field API fields transfered from config entities to content entities?

So I am creating a content and config entities - exactly like node and node type. After I've created them I've noticed that I can add fields to the config entities, which is ok but then I've realised ...
-1
votes
1answer
133 views

How are the 4 tables for revisionable and translatable entities in Drupal 8 meant to be used?

There are 4 tables for each type of entity, entity entity_revision entity_field_data entity_field_revision How exactly are the individual tables meant to be used?
8
votes
3answers
6k views

Devel dsm() function in Drupal 8 page.html.twig

Is Devel module's dsm() function available in page.html.twig? If it is not available, is there a way to make it available? I am able to use dsm() in .theme file but not in page.html.twig. I am ...
7
votes
1answer
4k views

Working with template suggestions on Drupal 8

I need Drupal to use a custom page template if the URL contains a particular _GET parameter. In D7 I would do something like this in the theme's template.php: function mytheme_preprocess_page(&$...
7
votes
2answers
7k views

Printing field item attributes with Twig / Drupal 8

In Drupal 7, I can do this in a custom field template to print the alt tag of an image: <?php print $item['#item']['alt']; ?> And though "item" seems to be a variable in Twig / drupal 8 fields,...
2
votes
1answer
2k views

How to perform a REST request after a node created using rules?

I have a backend service written by Python, which is exposed a JSON api. And I want drupal to perform an HTTP POST/PUT/PATCH/DELETE... request with json data (which is an output of a node) to the ...
3
votes
2answers
2k views

Using drush on drupal 8?

Dursh works very well with my Drupal 7, but when I try running Drush on Drupal-8 directory it throws some error message, $drush pm-list Command pm-list needs a higher bootstrap level to run - you ...
3
votes
1answer
543 views

Issues with namespaces and Migrate module migrating XML content

In the Migrate module I noticed that one reason I could not import an XML file was because it contained namespaces. Removing namespaces from the XML file and Migrate class allowed me to import the ...
16
votes
4answers
20k views

How do you implement a custom submit handler in hook_form_alter()?

I've been updating one of my Drupal 7 modules to 8 and I'm having an issue with my form alter. I'm adding a validation function and a submit handler. The validation function is getting called just ...
3
votes
1answer
779 views

Create Node contains Field collection with restws + services

I am trying to create a node with RESTFULL api using restws and services modules (latest versions) on Druapl 7 - openpublish destro. the node contains a Field collection (images field collection field)...
0
votes
1answer
1k views

How to display JSON returned (from external REST API) in a Block? [my code attempt inside]

I am trying to display the data from a REST API (URL: 'http://api.kivaws.org/v1/loans/38239/lenders.json') to display in a block. Below is my code. It is not working, any hint on why will be sincerely ...
8
votes
5answers
8k views

Adding JS to a Drupal 8 theme (replacement for drupal_add_js)

In Drupal 7, I can use drupal_add_js within a theme's template.php file as a theme_preprocess_html(&$vars) function: drupal_add_js(drupal_get_path('theme', 'mytheme') . '/js/scripts.js', ...
5
votes
3answers
9k views

Trying to render a custom date format with Twig

I'm in the process of porting one of my contrib themes to Drupal 8. For custom date formats on nodes, I have something like this in a node_preprocess function in the theme's template.php file in the ...
1
vote
1answer
255 views

Is updating the composer.json file & consequently composer.lock in Drupal 8 considered a good practice or hacking the core?

I have been working with another developers on a scaffolding tool for Drupal8 based on Symfony Console component. The current setup process includes updating composer.json using composer CLI: ...
5
votes
3answers
2k views

RedirectResponse not working

I'm in the process of porting my modules from D7 to D8. No real problems so far, but... I have a multistep form from where I need to redirect to /node/add/xyz in the last step. (All required input ...
11
votes
1answer
8k views

How to create custom entity in Drupal 8 [closed]

I have a big personal project build on Drupal 7 that has many custom entities. I want to start upgrading the project into Drupal 8 but the completly rewritten Drupal 8 core is too big for me to get my ...
2
votes
3answers
310 views

Is registering a controller as a service still frowned upon in D8

In the presentation given in Portland by Kat Bailey in May, registering a controller class as a service was highly discouraged, however a lot has changed since then and I wanted to check if this is ...
5
votes
1answer
1k views

How do I construct a thin controller with a dependent service?

For the first time I am trying to architect a reasonably complex Drupal 8 module, and not sure of best practice for the controller. I need to route paths to a controller. I intend the controller to ...
10
votes
3answers
6k views

Multistep/wizard forms

I'm trying to create a multistep/wizard form for Drupal 8. User fills in a first name, last name fields Clicks on the next button Fills out more information Clicks on the submit button There are ...
4
votes
1answer
4k views

Non-CRUD resource action with Drupal 7 / Services 3

I can't get this simple example working with a custom action. I had to move it form here How can I create a simple non-CRUD resource action with Drupal 7 / Services 3? to an own question. The ...
4
votes
1answer
2k views

Define JavaScript library in Drupal 8

In Drupal 8 some javascript changes were introduced so now all js scripts should be defined using hook_library_info() and added to the page only with #attached attribute of the render array. But what ...
4
votes
1answer
12k views

Trying to install Drupal modules and themes: keep getting error “does not contain any .info.yml files.”

I am new to Drupal. I am running Drupal 8. I have tried to install three different themes and modules, and keep getting this error: does not contain any .info.yml files Including with the Beale ...
2
votes
0answers
168 views

Why the routing system has been changed in Drupal 8? [closed]

In Drupal 7, some part of hook_menu was used for routing and registering paths (That is what I have read). I read an article about Drupal 8 and it said that one of the biggest changes in Drupal 8 is ...
24
votes
1answer
3k views

Why are routing files filled with underscores?

What is the deal with all the parameters with, and without, a prefixed underscore character? Where does Drupal decide how to process these parameters? Was this concept introduced from Symfony, or is ...
0
votes
1answer
5k views

Cause for Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: error

Currently trying to port over a Contrib module and learn the new Drupal 8 architecture. A google search revealed a possible issue related to this. The cause could be that there's an underscore in ...
4
votes
2answers
2k views

How can I setup a site with Acquia Dev Desktop 2 beta?

I'm using the new version of Acquia's Dev Desktop beta 2 (https://docs.acquia.com/dev-desktop2) and I want to use it to test and develop on Drupal 8, but it seems tied to a specific set of ...
2
votes
3answers
3k views

Add a non-base field to a content entity form

What is the proper way to add a non-base textarea field to the entity form of a custom content entity? comment and user modules have non-base fields that display in their entity form (comment_body ...
2
votes
1answer
282 views

How is a TypedData value validated?

I do not understand how the Boolean (just for example) is validated. This is my code: $tdm = \Drupal::typedData(); $data = $tdm->create(array('type' => 'boolean'), 1000); drush_print_r($data-&...
3
votes
1answer
3k views

Add multilingual support to Drupal 8 Hello World module [closed]

Today we already can upgrade contrib projects to Drupal 8 (#D8CX) and there are more and more “Hello World” code examples for Drupal 8. Some of them: Drupal 8: Writing a Hello World Module Drupal 8: ...
1
vote
3answers
3k views

How to configure REST server to create new node from URL parameters?

Drupal 7.23 Services 7.x-3.5 I've followed the instructions for setting up Services module, including https://drupal.org/node/1699354. I got the endpoint setup successfully. I am able to retrieve ...
0
votes
1answer
4k views

Using Doctrine in D8

I have downloaded the latest version of Drupal 8 my project structure looks like: private/ EntityOne.php EntityTwo.php Test.php => Test Script (Eventually AUT) public/ index.php => ...
5
votes
2answers
8k views

CMS Vs Framework? Is Drupal A CMS, Framework, or CMF (Content Management Framework)? [closed]

After Reading a Blog post: http://www.palantir.net/blog/drupal-not-cms It made me curious about the current classification as CMS Vs Framework. Please use Facts, where possible to justify your ...
2
votes
0answers
316 views

Checklist for drupal developers to be ready for drupal 8 [closed]

As Drupal 8 will be using symphony framework, what will be the best learning path for developers to get ready to adopt for Drupal 8.
8
votes
1answer
308 views

How to change core's default services

Dependency Injection is added to core, but there's no documentation to tell how developer can alter the default services. For example, I would like to change cache.bootstrap class to APC Caching.
1
vote
2answers
96 views

Page title always displaying “Error”

I am porting the Disqus module to Drupal 8. The new routes are working fine, except for the page title, which always displays "Error" instead of the desired title. I have already implemented ...
1
vote
1answer
659 views

Will painless upgrading from Drupal 8 alpha 3.x to beta be possible? [closed]

I'd like to create a website with Drupal 8 Alpha 3. But I'd like to know for sure if it's possible to do a harmless upgrade to Drupal 8 Beta once that it's released. I heard something about the ...
5
votes
3answers
4k views

Custom #ajax “Add another” button only adds 1

This form consists of 1 textfield, and 1 ajax button. I'm trying to make it add another text field with each click. It works for the first one, to get a total of 2 text fields. I cannot get more ...
4
votes
1answer
1k views

What arguments can I use when defining a service?

Looking at system.services.yaml, I noticed that some of the services arguments are strings starting with @. They seem to contain a reference to another defined service. system.manager: class: Drupal\...
4
votes
1answer
937 views

How can I convert the code that used drupal_get_http_header() to check if Drupal returned a 403 or 404 error?

I have a module that in hook_preprocess() checks with drupal_get_http_header() whether Drupal is returning a 403 or 404 error, but in Drupal 8 that function is deprecated, since header handling is ...
2
votes
1answer
103 views

Is there any case where a module needs to implement a class using ServiceProviderInterface?

Drupal defines the CoreServiceProvider class which is used to add the twig, twig.loader.filesystem, and module_handler services. Since the Drupal 8 way to register a service from a module is using ...
2
votes
2answers
962 views

How to extends %module_x/templates/xyz.html.twig?

My module has a template which would like to extend another module's template. Is there any shortcut like we have in Symfony2? {% extends 'path_to_module_x:templates/template-x.html.twig' %}
3
votes
1answer
354 views

Where is Twig service defined?

In twig_render_template(), I see this drupal_container()->get('twig')->loadTemplate($template_file)->render($variables). But I can not see where the twig service is defined.
7
votes
1answer
1k views

How to manage contrib modules composer dependencies on drupal 8

Let's say I have a module exposing a composer.json file, composer manager let me merge it with others modules composer.json. In Drupal 8 composer.json are used from the core, so is it possible to ...
6
votes
4answers
4k views

Expose custom entity to views

I've created an entity in a Drupal 8 custom module. Right now it's just an entity with base fields. I want to expose these base fields to views. I have the entity appearing on the views wizard page, ...
41
votes
4answers
2k views

What is the suggested workflow for migrating (CMI) configuration from dev -> stage -> production?

We had a drupalcamp a few months back and someone asked about managing deployments with the new config (CMI) system. One possible ideal workflow would involve keeping the config in version control and ...
11
votes
2answers
363 views

When should I use methods, get() and magic offset

There are three different ways to get an entity value, for example the node content type. $node->type->value $node->getType() $node->get('type') Which one should I use?
10
votes
3answers
2k views

Is hook_init() still used? If it is not anymore used, how do I convert code implementing hook_init()?

Looking on Drupal.org API, I noticed that hook_init() is not documented for Drupal 8. Looking at the change records, I found Bootstrap hooks no longer exist, which points to Get rid of all 'bootstrap' ...
52
votes
2answers
28k views

What are all the directories for in the new Drupal 8 structure?

Drupal 8 re-arranged all the directories and locations of modules/themes etc. Where do things go now?
0
votes
1answer
3k views

Passing custom fields as parameters in a REST query

I am creating a REST Get request using Services 3.3 module on Drupal 7.15 which should get all the nodes filtered by a custom field field_asset_type http://sharedrive/?q=rest/node&parameters[...
3
votes
2answers
903 views

How do I get comments to be indexed?

I'm not sure if it's actually doing this; I can't see any options for comment fields in the configuration. How can I check? Does it say explicitly somewhere?