Stack Exchange Network

Stack Exchange network consists of 174 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

Use it for questions about rendering or modifying the HTML markup produced by a module/theme.

0
votes
0answers
23 views

Getting field value on twig used in a panel page

I am trying to get the value of field that is displayed in a panel page. I might be going about this all wrong because I'm still getting used to Drupal 8. I want to display book information, including ...
0
votes
0answers
26 views

Overwrite default (Bartik) block.html.twig from my custom block module folder [duplicate]

I have a custom block module. I want to override core/themes/bartik/templates/block.html.twig in my-module directory. In my-module directory I have a folder templates/ and the twig file block--my-...
0
votes
0answers
16 views

How to use Flag and Message modules to follow an entity? [on hold]

I installed on "Drupal 8", the modules "Message" and "Flag". I created a "Flag" named "Follow". What I want to do : 1) a user follows a store 2) a new product is created in the store 3) a message ...
0
votes
0answers
15 views

How to display the rendered entity of the user?

When I install the Message Example submodule, it is possible to display the rendered entity of a node with the token [node-render]. How to make a user view mode? What code should I add for in ...
0
votes
1answer
13 views

Can not use a comment display mode

In my comment type, I created a "teaser" view. When I enable the debug mode in the "service.yml" file, the display modes of the comments do not appear in the suggestions. Why ? How to use a ...
-1
votes
0answers
9 views

Underline of a tag is not removing [on hold]

Hey I have a tag in which I have an image tag. My problem is that on my page an underline is showing under my image. I tried setting text-decoration to none but of no luck. Kindly tell me how to ...
2
votes
1answer
28 views

Render View with title in twig template?

Is there a version of drupal_view (or alternative) that will render a view with the title? It's a pain to hardcode titles or preprocess individual views just to get a title to render that is already ...
0
votes
0answers
13 views

What could be preventing the default logo setting from being saved in a theme? [on hold]

I noticed this after creating a sub-them of Bootstrap_Barrio. After installation the default logo setting is ticked but after adjusting anything and saving, it gets toggled off and cannot be toggled ...
0
votes
1answer
11 views

Theme Suggestions for User Page

I want to create a separate html.tpl.php for user pages and user edit pages like html--user.tpl.php and html--user--edit.tpl.php. For nodes I have added: if (isset($node) && $node->nid) {...
-2
votes
0answers
30 views

change progmmatically site name (add some html tags)

I need to change site name in my drupal 8 site, text i can esealy change via cofiguration/system/basic site settings but if i want to add some html tag to part of my site tittle all html tags are ...
0
votes
0answers
24 views

Add SCSS to custom module root [on hold]

I have a small project where I create a custom module. I want to add styling to the custom module. But not provided by a custom theme, but all the styling (in this case) provided by the module. Is it ...
1
vote
2answers
16 views

Print multiple files field links, descriptions and file extensions in Twig

I have a content type with a field field_file_attachment that allows uploading multiple files with txt, pdf, gif and img extensions. I would like to get links, descriptions and extensions of all ...
0
votes
0answers
14 views

Add (background) image field to custom module block

I created a custom block module. How do I add an image field to the block configuration, so the user is able to upload a Background image to the block? Then with a theme hook I want to set image as ...
1
vote
2answers
10 views

Workbench Moderation: Published data overriding draft data on draft view

Moderation's draft content not showing on the front end. When a node has both a published and a draft, the data from the published overrides the draft data on the front end when viewing the draft. ...
0
votes
0answers
23 views

Call to undefined function gcd [closed]

I am making a custom module in which I am calling a function inside another function. I have defined that function in the class but I am getting this error call to undefined function gcd. I am sharing ...
0
votes
3answers
46 views

How do I check the value of a field if its empty?

Is there a way to check, in a preprocess function, if the value of a field is empty? I'm getting the following error. Call to a member function isEmpty() function ...
-1
votes
2answers
32 views

Getting an fatal error message when trying to render custom blocks on my node twig template

I'm trying to render or print my custom blocks on my node twig template and currently receiving a fatal error message. Argument 1 passed to Drupal\block\BlockViewBuilder::view() Here is the snippet ...
1
vote
1answer
31 views

Why is my text hyphenated?

I have a text field. When I enter text in the CKEditor the words look OK. But when I look at the rendered page, it seems as if Drupal has split all word instead of put the entire word in the next line....
0
votes
1answer
13 views

Trying to display/printing latitude and longitude from Geolocation Field to node template

I've been trying to figure how I can fetch the latitude and longitude values using geolocation field and display it on my node.html.twig template. I've been using to kint() to see how I would be ...
0
votes
0answers
33 views

Print individual user registration form fields in twig template

I'm creating a twig template which overrides the layout for a user registration form. How can I print the form fields individually? I've tried {{ form.email }} and {{ content.email }} to print ...
-1
votes
0answers
18 views

improve drupal 7 performance on nginx

I want to imporve drupal website performance. Already did settings for drupal cache & Advanced CSS/JS Aggregation. Also implemented the changes requested by gtmatix still it takes 20 seconds to ...
0
votes
1answer
14 views

Pre-process node type for each node and print within region.html.twig template

I'm trying to figure out how I can check the node type/content type for each node using pre-process and print it on a region template (region.html.twig) It seems to be returning NULL function ...
0
votes
0answers
37 views

Pass PHP variables from my custom block to my custom Twig template [duplicate]

I created a custom block module my_block. Inside modules/custom/my_block/src/Plugin/Block/MyBlock.php I have this code: <?php namespace Drupal\my_block\Plugin\Block; use Drupal\Core\Block\...
1
vote
2answers
31 views

How to send the emails related to the user account in HTML?

I want to send the emails related to the user account in HTML version: forgotten password new account account canceled ... If I make a copied paste of my HTML code, it does not work. /admin/config/...
2
votes
1answer
37 views

Different page--user.html.twig for different user roles

I have a few user roles - simple user, editor and contributor. How to make different profile pages for all of this roles? Now I can work with: FILE NAME SUGGESTIONS: * page--user--16.html.twig ...
-1
votes
0answers
20 views

How do I declare a new template file for my theme? [closed]

I recently built my first site with Drupal 8, off of the public beta. One thing I found very quickly was that online learning resources for Drupal 8—as compared to Drupal 7—were essentially non-...
1
vote
2answers
86 views

drupalSettings object not showing for anonymous users. core/drupalSettings is added as a library dependency

I'm stumped on this one. I’m having an issue where the drupalSettings object is empty when not logged in. Works fine when I am authenticated. - core/drupalSettings is in theme’s *.libraries.yml file. ...
0
votes
0answers
29 views

How to send custom user field to page--user.twig

I created a custom user field - field_editor How to display value of this field in page--user.html.twig? Thank you for help.
0
votes
0answers
23 views

Add for loop values and result into custom block and twig file

I have a custom block. In modules/custom/my_block/src/Plugin/Block/MyBlock.php I have some PHP code and this for loop: // Get number of current day. $day = date('j'); // Get number of current month....
1
vote
1answer
31 views

How to add template suggestion for user--VIEW-MODE--ROLE.html.twig

I used hook_theme_suggestions_HOOK_alter: function MYTHEME_theme_suggestions_user_alter(&$suggestions, $vars, $hook) { // Define the view mode. $mode = $vars['elements']['#view_mode']; // ...
0
votes
1answer
38 views

How to display custom user_field in user.twig

I created a custom user field -field_interes and I want to print this field in user.twig. Anybody can help me with this problem? {{ content.field_interes }} does not work. Thank you!
1
vote
1answer
16 views

Theme Preprocess Conditional Field Display

Looking for a way to preprocess two fields. I am trying to hide Field 1 from display if Field 2 has value. If Field 1 has value and Field 2 has value display Field 2 only. If Field 1 has value and ...
1
vote
2answers
31 views

How to get user.field value in node.twig

I have a field_author with different values expert, moderator or contributor For get this custom USER field in node.twig i using next function function MYTHEME_preprocess_node(&$variables) { if ...
1
vote
2answers
23 views

Managing custom theme translations file

How to add a translation file to a custom theme? I did my_theme.info.yml 'interface translation project': my_theme 'interface translation server pattern': themes/my_theme/translations/my_theme-%...
0
votes
1answer
25 views

How to customize the shopping cart?

This is a real puzzle, if I disable the image field of the display mode of variations, it is still displayed in the shopping cart. Can someone explain to me how to customize the shopping cart ? I do ...
0
votes
0answers
11 views

How do you set the attribute.id of a menu block?

Aria-labelledby has incorrect (ID) reference because the attribute.id is empty, resulting in the template generating a value of "-menu". faculty is the machine name of the menu block, the menu block ...
4
votes
1answer
33 views

Custom theme: variable not made available in menu template

I've created a custom theme, let's call it "mytheme" in the examples, with the "classy" theme as base. I use several templates, one is menu--account.html.twig, it's an override I made of the classy ...
0
votes
1answer
33 views

Linking an action to the button in the view

I'm looking for some tips how to achieve following functionality in Drupal 8. I have a simple view where I list filds, nothing special. One of the fields is a custom text which is rendered as a ...
0
votes
2answers
43 views

How to display the variation of a custom display in Twig

In my type of product variation, I have 4 different display : Default Panier (Cart) Teaser Teaser relation I have created a template for product type and want to display the "Photo" field of the "...
0
votes
1answer
6 views

Views block template print individual field from content

I created a view of paragraphs and I passed the parent ID as the contextual filter using a relationship to the content that use the field that reference the paragraph. I can see the data been ...
0
votes
0answers
14 views

How to add the terms of sale in the purchase tunnel?

I created a site with Drupal 8 and I have several stores (it's a marketplace). For the sale to be legal, the customer must accept the terms of sale during his order. Currently I have created a long ...
1
vote
1answer
34 views

Adding a flag to Menu Content Link to display as a non-link [duplicate]

I have been struggling/failing for the last day to try find a way that I can add a flag/marker to the Drupal menu links that I can examine within the menu TWIG template to modify the link such that it ...
0
votes
1answer
18 views

How to output variables from a multi-value field into html on a node tpl overrride

I have overridden my node tpl page and want to output variables from a field into html. The field is called: "Features Ticked" I understand that this php code will output the information: <?php ...
1
vote
1answer
47 views

Can I add CSS to a YAML generated page ?

(Sorry if that's Drupal 101, but I'm still at the very bottom of the learning curve ..) I have a custom module, with a routing file that redirects to a path that I have chosen arbitrarily : ...
0
votes
1answer
30 views

Kint works in pre_process but not in Twig

On my site, I'm able to use print variables using kint in my pre-process functions. However, when I try to do the same in twig, nothing happens. I do have debug mode turned on. Has anyone ever ran ...
1
vote
2answers
37 views

How to pass variables to overridden Twig template located in module?

I'd like to pass a variable to an overridden Twig template that is located in my custom module (not in a theme). Following this answer and this answer, I wrote this code in mymodule.module: function ...
1
vote
1answer
38 views

Programmatically Create an Array of User Objects and Print in Twig Template

MYMODULE.module: function MYMODULE_preprocess_node(&$variables) { if ($variables['node']->bundle() == 'content_type') { $currentUserUID = \Drupal::currentUser()->id(); ...
-2
votes
1answer
161 views

Sub-theme navigation menu and footer menu not showing

I have created a sub-theme using a purchased theme. While creating sub-theme I followed these steps as mentioned in the documentation: I have created subtheme.info.yml and subtheme.libraries.yml ...
0
votes
0answers
17 views

migrated site to server with newer ubuntu, php - theme not working

I've been migrating a number of sites (Drupal 7, 8, Wordpress) from one server running Ubuntu 14.04 and php5 to one running 16.04 and php7. Some of them work right off the bat and some have required ...
0
votes
3answers
35 views

grabbing data and displaying it in block twig

bI made a custom module and made a custom block inside of it. In the build () I have this. return array ( '#theme' => 'no_athlete_match_block', '#title' => 'Athletes With No Matching ...