Questions tagged [8]

Version tag to tag issues specifically related to Drupal 8.x. Please note that 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
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
1answer
2k views

Why do I get “Page not found” with my code?

I just created a new module but I can't manage to access it. Here is the home.info.yml name: Home description: Ownzones Homepage type: module core: 8.x Here is home.routing.yml home.oztest: path:...
9
votes
3answers
3k views

Get title of page

When I get the title on some pages, I get an empty title like Home. The code I am using in my subscriber is the following one. class HistorySubscriber implements EventSubscriberInterface { public ...
0
votes
2answers
360 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
2k views

How to compare dates in a View?

I'm trying to build a new View in Drupal 8. I want to display list of News. Each item has field_date where is date (without time) stored. And second field is body with basic text information. I'm ...
1
vote
4answers
3k views

Custom classes for menu links

How can I add custom classes for links into main menu in Drupal 8. This is template for my main menu called menu--main.html.twig {% import _self as menus %} {{ menus.menu_links(items, attributes, 0) }...
1
vote
2answers
9k views

Alter menu item markup in Drupal 8

I am trying to play around with Drupal 8 menu. How I understand now menu is a service, so how to alter menu output in Drupal 8? Is there any documentation? Because googling show no useful results. ...
9
votes
1answer
7k views

How to use #element_validate and #value_callback in Drupal 8

I have followed the official Form API Documentation, but this code don't work for me on Drupal 8: public function buildForm(array $form, FormStateInterface $form_state) { $form['upload'] = ...
10
votes
0answers
8k views

Drush : Missing $settings['hash_salt'] in settings.php [closed]

I just setup a new Drupal environment with Mamp. I can access my website just fine, but whenever I want to run drush cr I get the following error : exception 'RuntimeException' with message 'Missing $...
19
votes
6answers
22k views

Include a partial template

I'm trying to use Drupal 8, with a custom theme, due big structure differences for my requirements I have a page--front.twig.html and a page.twig.html, I would like to create template parts as used in ...
0
votes
1answer
39 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://...
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 ...
-1
votes
1answer
585 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/...
13
votes
6answers
14k views

How to embed a view in a specific node?

I try to embed a view in a specific node. I found tutorials for doing this with Drupal 7 and PHP-Templates: <?php print views_embed_view('view_name'); ?> But I look for a way in Drupal 8 with ...
0
votes
1answer
188 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
vote
0answers
278 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: ...
8
votes
4answers
8k views

Get an image from an article/entity

How do I easiest get an image (its path) from the article content type included in Drupal 8? What I have is an entity. Using $image = $node->fields['field_image'] gives me a hell of a structure, ...
-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
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 ...
1
vote
4answers
2k views

create a taxonomy and attach a field to it programatically

how can i attach a field to an entity (vocabulary) programatically in drupal 8 I created a vocabulary $vocab = entity_create('taxonomy_vocabulary', array( 'name' => 'vocab_name', '...
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,...
3
votes
3answers
7k views

Implementing CKeditor's plugin

I need to add the Templates plugin into Drupal8 CKeditor. So far it is available on the editor configuration page, but not on a node edit page. The code: namespace Drupal\module_name\Plugin\...
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 ...
0
votes
1answer
516 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 ...
0
votes
2answers
150 views

Auto-complete and form auto-populate from wikipedia

I have some taxonomy terms that would benefit from being (at least in part) being based on wikipedia articles. It looks possible to make a request via the wikipedia api in PHP, and then link that to ...
9
votes
6answers
19k views

What function/method can I use to redirect users to a different page?

In Drupal 7, I use the following code. function my_goto($path) { drupal_goto($path, array(), 301); } What code should I use in Drupal 8?
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
3answers
253 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 ...
2
votes
1answer
846 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, ...
6
votes
4answers
6k views

HTML isn't rendering, HTML tags are being printed

I added a view template views-view-fields--nieuws--page.html.twig to my theme. The template is correct, when I edit it I see the results on my website. {% for field in fields %} {{ field....
7
votes
5answers
8k views

How can I get image url in a views field, D8

The D8 Views image formatter has only one option: Image. I would like to get the url that's in the markup, not the markup, in my views field output. Do I need to make a custom formatter, or is there ...
1
vote
3answers
828 views

drupal_render() and formBuilder's getForm

What exactly is the best way to accomplish this? I can pass the $form object returned from getForm to drupal_render() and get the correct themed output fragment but the API docs say this function will ...
3
votes
1answer
427 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 ...
1
vote
1answer
144 views

Basic “empty” entity type? [closed]

Is there a module that provides an empty entity, to which I can add my own fields. I guess it would include just an Entity-ID as a primary field, and work with other entity modules. For me, nodes ...
3
votes
1answer
4k 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
2answers
267 views

Adding a reference to a bundle in a node

I would appreciate suggestion for this common scenario in Drupal 8, which may be different to how I do it in Drupal 6. I don't want to do any programming. I have two content types: (1) Articles (...
42
votes
15answers
72k views

Getting the image URL from a field_image on a node

So I have this Node: object(Drupal\node\Entity\Node)[1862] protected 'values' => array (size=17) 'vid' => array (size=1) 'x-default' => string '7' (length=1) ...
2
votes
3answers
2k views

How to disable Toolbar on certain pages / theme?

Before deprecation of hook_page_build/hook_page_build_alter() we used good old method: $page['page_top']['toolbar']['#access'] = FALSE; (Source) It disabled Toolbar for specific route in specific ...
3
votes
2answers
2k views

How can I create menu links to external URLs?

With my module MYMODULE I would like to create external link and place it into main menu. Is it possible to do that in MYMODULE.links.menu.yml file or MYMODULE.routing.yml? Something like this??? ...
1
vote
0answers
98 views

Is there a way to retrieve DRUPAL TWIG template's with core drupal 8 javascript functions like twig.js?

Is there a way to get precompiled twig templates from drupal 8? Example : Drupal.getTemplate('my-template.twig')(data);
2
votes
3answers
2k views

Get field widget settings

In Drupal 7 they can be found in object that is returned by field_info_instance(). Is there a way to get widget settings for certain field name and bundle in Drupal 8?
2
votes
4answers
2k views

How do I access update.php using nginx?

I would like to use Drupal 8 (beta) with nginx. It works correctly, except update.php. It doesn't find it. After analysing .htaccess (which is not processed by nginx) I realized that there is no real ...
2
votes
2answers
1k views

Using entity form display modes

I have created a custom form display mode my_mode for nodes and wish to display node form using this mode instead of default one at a custom page. How can I do it? $this->entityFormBuilder()->...
4
votes
1answer
1k views

How do you pass more than one node to a route?

I am working on converting a drupal 7 site to drupal 8 for some practice with 8. In my drupal 7 site, I have a custom hook_menu declaration with the following: function solution_menu() { $items = ...
2
votes
1answer
308 views

Will Drupal 8 Twig have template inheritance like Drupal 7?

Drupal 7 you can style down to the fields on the page will we have this type of control with twig? I have reviewed a lot of documents about twig and didn't see anything that lets you have that same ...
5
votes
2answers
10k views

How do I redirect to an external URL?

Drupal 7 has drupal_goto() that would allow redirecting to an external url. The change record indicated that ControllerBase::redirect is the method to be called in D8. https://www.drupal.org/node/...
0
votes
1answer
280 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 ...
7
votes
2answers
10k views

How do I override a field template?

I am trying to override a field template with my own one. The field is called field_test, so I created a field--field-test--mynodetype.html.twig template file ` in root-theme-directory/templates/, but ...
2
votes
2answers
148 views

How do I add a project?

How do I add a Drupal 8 project (e.g. the Panels module) to my site?
0
votes
1answer
71 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 ...