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
2
votes
2answers
915 views

Drupal 8 JavaScript and Best Practice

I am building a theme for Drupal 8 that I want to make available in the drupal.org theme section. As such, I want it to conform to best practice code wise. When adding JavaScript, I notice there has ...
1
vote
1answer
324 views

Ajax button in admin

So I figured I'd create a configuration for my module. I created a normal form with some fields to let the users configure the module with variables. I also added a button which would do an ajax-call ...
3
votes
1answer
2k views

Replace Standard Node Path in Drupal 8

I am still new to all the Symfony semantics. What would be the easiest way to change node canonical urls to be /article/[node-title] instead of /node/[node-id]? Following this documentation I tried ...
2
votes
2answers
3k views

Drupal 8 Theme Header Background Image Upload

I'm upgrading the Mayo theme to Drupal 8. For Drupal 7 it worked like this in theme-settings.php with hook_form_system_theme_settings_alter(): $form['adv_header']['header_bg'] = array( '#type' =...
-2
votes
2answers
50 views

What is proper way to update D8 DEV? [duplicate]

I'm not having any luck with Drush (just hangs) to update a (non-production) D8 site, dev branch (from around beta2) to Head. How would one manually update the files db/config?
0
votes
0answers
781 views

How to add menus to my footer block (nested blocks)

I created a module in Drupal 8 called Footer and made it a block so I can include it in my Footer region in my theme. I need my footer to have two menus, one listing topics and one listing static ...
3
votes
1answer
134 views

Can I register an additional namespace to point to the modules folder

In Drupal 8 is it possible to register an additional namespace which points to the modules folder in addition to the \Drupal namespace? e.g.: MyOwnNamespace\{module_name} to point to $...
12
votes
2answers
3k views

Sub folders and how to namespace classes

In Drupal 7 I can have a module inside another module. Is this still the case in Drupal 8 and how would I namespace classes inside the sub module? Another thing I can do in Drupal 7 is to create sub ...
0
votes
1answer
92 views

Upgrading drupal 8 beta3 to beta4 table user__roles not exists

When I upgrade my drupal site to beta4 release, it says that table user__roles is not exits. It's look like that new beta version alter table name from users_roles to user__roles. how is possible to ...
1
vote
1answer
1k views

How do I apply check_markup() as Twig filter?

I am trying to modify output in my twig file. In D7, I was able modify data in my array with this check_markup($tweet->text, 'full_html'); and I see that this function still exists in D8. However,...
2
votes
3answers
1k views

Drupal 8 field API vs. $form_state

I am creating a field with Field API, and having it shown on user registration form. However, I need its value in order to make validation. For that purpose, I've used dpm($form_state) which gave me ...
0
votes
2answers
359 views

Receiving http status code 406 [closed]

I have created a custom module in Drupal 8 and added the routing table to mymodule.routing.yml. Whenever I am trying to hit a particular path, I am receiving the HTTP response "406 (406 Not Acceptable)...
1
vote
1answer
94 views

Manual setup of user's language

I need to switch user's language programmatically. The issue is I don't want it as an url part, and unable to switch it even with the regular language switcher block. What I've try: admin/config/...
3
votes
1answer
3k views

Override image-formatter.html.twig

I'm looking for an option to override the image-formatter.html.twig template in my own theme. But in the HTML page output (twig debug is set to true) there's no option listed to override the formatter ...
0
votes
1answer
505 views

How to create a custom handler in view?

I am trying to alter a field's argument handler. But It is showing me broken/missing handler in view's argument. I have tried it in following ways : I am adding the following two code block in ...
3
votes
1answer
422 views

Drupal 8 multilingual node edit

I have a multilingual setup, and the content translation works well and smooth. But when I try to edit a node on the other language - I have the same link from the content admin menu, which renders ...
0
votes
1answer
38 views

Use Plugin Field inside buildForm()

In Drupal 8, I use this code inside my buildForm() method: $form['medias']['file'] = array( '#title' => t('Image'), '#type' => 'managed_file', '#upload_location' => 'public://...
2
votes
3answers
247 views

Equivalent of search_data() in Drupal 8

Is there any function equivalent to the (D7) search_data() in Drupal 8? I would like to get the search results as a renderable array or html for a given keyword programatically. In D8, the ...
1
vote
1answer
1k views

Embed a collection of form inside a form

With Symfony2 I can embed a collection of form inside an another form (subform inside form). http://symfony.com/doc/current/cookbook/form/form_collections.html I would like know if it's possible ...
0
votes
1answer
187 views

RESTws POST List (text) field type Error

I'm using RESTws and POSTing a JSON object to "/node". Everything works fine until I include a List text field (checkbox type). The field in question is: ... "field_days_closed_v": ["Monday", "...
-1
votes
1answer
581 views

How to retrieve specified fields using services?

Using services we can retrieve list of all nodes with different filters and we can get a specific node as well. But is there any way we can specify the fields we would like to retrieve ? Eg: api/node/...
4
votes
3answers
4k views

Prevent caching of a node

I'm working on facebook like button for drupal 8. It's about to be done, but I've faced a trouble. Whenever I change the configuration of my module, I still need to clear all caches manually for the ...
1
vote
1answer
256 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: ...
1
vote
0answers
277 views

Making a 'contains' type GET query over a REST API, with Services?

I've installed Services (and Services Views) so I can expose my drupal site as a RESTful API. All my filters are working, but not the one that queries a taxonomy term array. Here is an example JSO: ...
1
vote
1answer
1k views

Problem with a query

On Drupal 8, I have this line inside my form (my_module/src/Form/MyCustomForm.php). $users = db_query('SELECT * FROM {users}'); var_dump($users) shows an object (of my query) and not the list of all ...
-2
votes
2answers
103 views

How install a module without break the installation if error

When I install my module, I get the following error: Declaration of Drupal\media_gallery\Form\GalleryForm::create() must be compatible with Drupal\Core\DependencyInjection\...
1
vote
1answer
5k views

Generating internal URL/redirect by path>

In the past I could set up redirects with drupal_goto using a simple path (i.e., node/1). Is this not possible at all in Drupal 8? Everything I've seen relies on a route name but that requires either ...
2
votes
1answer
821 views

how to debug drupal_http_request

I'm working on a module that takes a form submission and posts it to a rest api, using the webform validator module's hooks. I'm trying to debug what's going wrong, and I have the following code, ...
1
vote
1answer
312 views

Access denied while deleting an entity

This is my Config entity: * @ConfigEntityType( * id = "myentity", * label = @Translation("My Entity"), * controllers = { * "storage" = "Drupal\Core\Config\Entity\ConfigEntityStorage", ...
0
votes
1answer
273 views

Add content to same page drupal 8

I got a drupal 8 home page wich works fine but all my content on that page is in the same textbox like this image here: How can I make it so I can seperate this content and still show it under each ...
0
votes
1answer
70 views

write data in another drupal website / rest

I need to implement the following setup: - master site (drupal 7) - child site (drupal 7) User create/update nodes in the master site. Then the nodes should be copied to some child sites, depending ...
4
votes
2answers
2k views

How do I in code add new field values to a D8 content entity?

How do I in code, create a new field value, add it to a content entity, and then have it saved to the DB? Field API is dead. Long live Entity Field API! clearly shows how to read values, but doesn't ...
1
vote
1answer
77 views

Generating Url for a route

I want to use drupal l() function, but Url doesn't work really well with a view with optional argument. The view has a context filter, but it is optional. In the routes table it has path /knowledge-...
0
votes
1answer
388 views

Running drush from a minimal shell

My goal is to pipe mail with Postfix into a drush command. I made a simple bash script that redirects stdin to the drush command, and I configured Postfix to pipe mail to the script. But executing ...
1
vote
1answer
548 views

How to extend/override Rest EntityResource Plugin in Drupal 8

I would like to extend/override the Rest EntityResource Plugin in Drupal 8. I have read everything I can find online and I can see how to create a resource plugin for something other than an Entity (...
9
votes
1answer
810 views

How can I install composer packages with drush make?

How does one include composer package in a drush make file? The more general answer, the better. There's already a composer drush module allowing drush dl to handle composer packages, but that ...
2
votes
2answers
574 views

Writing functional tests for a controller that makes call to external service?

I'm working on the D8 version of the CAS module. To integrate with a single sign on CAS server, this module will have to redirect the user to the CAS server often, and occasionally make cURL requests ...
0
votes
1answer
1k views

How can enable multiple contact form in drupal 8?

I want multiple contact forms(different fields) in my drupal 8 site Like Webform module drupal 7. I have tried to add multiple contact forms and i am able to number of contact forms with different ...
2
votes
1answer
71 views

Web services for specific node

I know you can enable Web services for content in Drupal8. You also need to set permissions to make a GET request to content. But I was wondering if it's possible to set for each node if it can be ...
-3
votes
1answer
1k views

Why Twig and not Blade in Drupal 8? [closed]

I was lately asked the question why Drupal 8 uses Twig as templating engine and not Blade, which is used in Laravel. I couldn't answer the question. But is there a specific reason why Drupal 8 uses ...
9
votes
1answer
6k views

Trying to add an html head tag in Drupal 8, beta 2

With Drupal 8.0 beta2, drupal_add_html_head() has been deprecated in favor of #attached. So the old way was: function MYTHEME_page_build(&$page) { $viewport = array( '#type' => '...
1
vote
2answers
703 views

D8: How to perform ajax call in javascript

I'm trying to perform an ajax call from a javascfript file by executing this: $.ajax({ url: '/lunapark/ajax/space-invaders/' + score, success: function (...
2
votes
1answer
190 views

How do I get a hold of the session object in my form handler?

I have build a form in D8 and on submit I want to save the form values into a session, so that I can access them 3, 4,.... page requests later. In D7 I just used $_SESSION['key'] = $value I have a ...
0
votes
0answers
28 views

Name space in rest service

I'm using the Services module for rest services. Is it possible to add my custom namespace in rest XML output.
0
votes
2answers
677 views

Getting error after install drupal8?

I have installed drupal 8 . During installation i am getting the below error Drupal requires you to enable the PHP extensions in the following list (see the <a href="http://drupal.org/...
2
votes
1answer
124 views

How to attach browser-specific stylesheets in D8?

In D7 it's possible to attach a css file based on browser sniffing, like this: drupal_add_css( $path_to_css, array( 'browsers' => array( 'IE' => 'lte IE 9', '!IE' => ...
1
vote
1answer
2k views

How to populate an autocomplete using a web service?

I want to populate a form field, an autocomplete widget, with values from an external REST web service without actually importing the data to my database first (on-the-fly). How do I do that? Is ...
5
votes
3answers
5k views

Problem installing REST Server module

When I attempt to enable the REST Server module, I get the following error message: A library is missing for rest_server to work (Currently using Missing library Please download spyc and create a ...
8
votes
2answers
5k views

How to force regeneration of Twig templates?

Twig generates classes for its templates. These classes are effectively caches by being written to disc. Generally speaking, one probably doesn't need to bother with the details of how the twig ...
1
vote
1answer
224 views

POST taxonomy item using Services module

I want to POST a new taxonomy item. I'm using Postman in Chrome to test, I'm logged in fine, and I'm posting RAW JSON: { "name": "building", "description": "", "vocabulary" : { "id" : 1, ...