Questions tagged [theming]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
18 views

Get data from one editor field and pass that into another editor field

I have no idea if this is even possible, but I figured I'd ask anyway. I'm working with a site that is on Drupal 8, and long story short, we don't have access to extending nor updating much so any ...
0
votes
1answer
183 views

How can I remove the black line from top and bottom of Entity Print output?

I'm using the Entity Print module with TCPDF. Is there a way I can remove footer and header? I did in Drupal 7 by editing the print_pdf.pages.inc file, but I wasn't able to locate the same functions ...
0
votes
1answer
394 views

How do I check radio buttons in Twig template?

In a form, I have this field: $form['payment'] = [ '#type' => 'radios', '#title' => $this->t('Payment Mode'), '#options' => [ 'chk' => $this->t('by check'), 'tfr' =&...
1
vote
1answer
413 views

How can I print user field values in page.html.twig?

I've created a couple of fields for the user in Drupal 8, example: first name. And i'm trying to print it in the home page (page.html.twig) but to no avail. I tried the following: {{ user....
4
votes
1answer
86 views

How can I programmatically get the admin theme

Similar question to How can I programmatically get the theme name? and How do I programmatically change the admin theme?. I want to simply obtain the current admin theme machine name and human name,...
0
votes
1answer
51 views

Render an HTML element before the menu with hook preprocess menu

I want to render an HTML element like <span>This is my menu</span> before my menu. I thought the most easy solution is to alter the menu. I already altered my menu to add a class. But how ...
1
vote
1answer
25 views

Add text message under “Add new comment” title

I would like to add a disclaimer message under "Add new comment" title and above the form in drupal 8 site. I changed the help text on this path /admin/structure/types/manage/article/fields/node....
0
votes
1answer
102 views

twig check if image style or view mode exists

I have a site design the i need to implement. in this design I have a grid and in the grid I can put any content (node/paragraph) that i choose. the image of the content changes size and ratio in ...
0
votes
1answer
50 views

How can I have multiple content types pick up the same template?

I want to override the template for 5 content type that they have all the same attributes, but a different name ,so the suggestion is : node--contenttype1.html.twig node--contenttype2.html.twig ...
-4
votes
1answer
39 views

How can you separately get the name and the value of a field?

I want to get the key and the value of my row for example I have this: {{ content.field_nom }} but the out put is: my field name my value My question is how do you get 'my field name' alone ...
0
votes
0answers
63 views

how to get values for my content type drupal 8

i have a problem to get values in my twig for my content type , i have just the '{{content}}' variable with a lot of arrays , how can i get for example my field 'field_image' ? <div{{ attributes....
-1
votes
1answer
267 views

How can I use Twig tempalte to handle label of form input field?

In a custom module (association), I have a form (MembershipStep3). I'd like to use Twig template to handle form fields titles and need some advice about that. In association.module, I have this code: ...
0
votes
0answers
34 views

Path to image file in theme folder for use with image_style

How can I use image_style settings on an image in my theme? The twig way I use for images, which are stored in fields is like this, with the help of Twig Tweak and Twig Field Value modules. <!-- ...
2
votes
1answer
423 views

How can you display document file sizes next to a media link button?

I'm trying to display the file size of a file next to a media link button on a page. I have two content types with a media entity reference field in each. Each field is restricted to only pull from a ...
1
vote
1answer
78 views

Twig: How to access multiple values from node reference field with number_format

I'm adding fields to array: {% for item in content.field_notes | field_target_entity %} {% set field_component_pages = item.field_component_pages|view|number_format %} {% endfor %} In my ...
1
vote
0answers
25 views

How to add a span before my menu title link [duplicate]

This is the default Drupal menu: <ul> <li class="menu-item parent"><a href="" title="">0.0 Bla</a></li> <li class="menu-item parent"><a href="" title="">...
2
votes
1answer
212 views

How to check if a link field uses <nolink> in template

I have a Custom Block type. It has a link field that allows <nolink> In the twig template for that Custom Block type I want to check if the link field has <nolink>. I can see there is a ...
0
votes
2answers
81 views

Display custom profile field in twig

In drupal7 I used this code in my template file (node--article.tpl.php) to display the author bio. This is a custom profile field named field_author_bio. <?php print user_load($uid)->...
0
votes
1answer
93 views

How do I override a view template in my theme folder properly?

I do not know if I am something missing, but I have a View in Drupal 8 and wanted to make a Template override in my theme, where I would print-out the image URL of one field and set it as "background-...
0
votes
0answers
56 views

How do I theme view fields, with custom templates or overwriting the output from the UI?

I am having some confusion in theming a view output in Drupal. While theming a view with Fields, you can either create template files for every view like views-view-unformatted--view-name--block-name....
0
votes
0answers
55 views

The default favicon shows up while the page is loading but it switches to my custom favicon after

I have my custom favicon.ico set up in my themes custom folder and it renders correctly for every page on my site. However, in the process of it rendering, it flashes the default Drupal logo for a ...
1
vote
1answer
203 views

Line break Twig question

I want to add line breaks in title field I managed to use the replace functions in the template > {{ node.getTitle()|replace({'|': '<br />'}) }} Replacement works, but outputs the field as non-...
0
votes
0answers
26 views

Session cookie is causing a problem in a custom RSS feed in my theme

I use Drupal 8.7.11. I personalized the RSS feed via a function in my theme my_theme_preprocess_views_view_row_rss() in view.inc file. I added this to add content:encoded tag in RSS feed called ...
0
votes
0answers
31 views

How to embed login form into registration form?

I am trying to place the login form next to the registration form (actually in a modal; but not relevant). I have a template suggestion in my .theme file to allow templating the registration form: ...
0
votes
0answers
31 views

Taxonomy term name in page.html.twig [duplicate]

I have a list of taxonomy terms to make some categories on my website. When I click on one of them, the content appears, but I can't display the taxonomy term name. I can't find the right ...
0
votes
1answer
43 views

Printing a date in a template file

Every time I want print a date I get this error. Warning: Illegal offset type in isset or empty in Twig\Template->getAttribute() Warning: array_key_exists(): The first argument should be either a ...
1
vote
0answers
53 views

How can I set Focal Point coordinates in a View or Twig?

I use the Focal Point module in D8, and I'm trying to figure out how I can access the X and Y coordinates of the focal point through Twig in either a view or Twig template so I can use them as ...
1
vote
1answer
145 views

{{ drupal_view('view1', 'block_2') }} renders only when cache is cleared

I like to output 2 block-views in a template called "block--bar.html.twig", but only when i clear the cache they are printed. (i installed Twig Tweak 8.x-2.x) This is the template: <section{{ ...
0
votes
0answers
52 views

How do I access the parts of twig.html arrays that start with a #?

I am trying to make an html.twig file and change how a paragraph renders its content, but I can't access the part of the array that has the info I need. This is the vardumper line I used to get this ...
-1
votes
1answer
50 views

How do I inherit from the base theme?

I want to inherit from the businessplus_lite theme I use as base theme, but I can't see any CSS applicable. There is just a board template blank with articles. Can anyone tell me how I can inherit the ...
0
votes
1answer
66 views

How to render element array piece by piece

I have template form.html.twig Drupal commerce is using it to render cart form. I made override of that template, to be able to change it only for cart form, without affecting other forms. That part ...
0
votes
0answers
33 views

How do you get file assets off the server in twig?

I have a small part of a website that relies on a bunch of csv files. When I built the site I just used the following code to grab the csv files, however I am now getting 404 not found errors. ...
0
votes
1answer
276 views

How can I generate custom XML for a SOAP client?

Im building a SOAP client that consumes from a SOAP web services in a Drupal 8 module. I need to generate this final XML: $inpunt_data = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap....
0
votes
1answer
93 views

How can I print the file size and other file info in a Views field template?

I have created a content type with a number of fields including file fields. In the node template for that CT (node--unit.html.twig) I am able to get the details with the following code: {% if ...
0
votes
0answers
35 views

How to print multi step webform current step number from webform page template?

I have template named page--webform.tpl.twig which is kind of wrapper for multistep webform. I would like to print current step of the webform from that template. Is there a way to access current ...
0
votes
1answer
22 views

Node values not retrieving properly in .theme and Twig files

I created a content type and have a couple of fields: a heading, links, and images. After creating a node out that content type, I want to pull parts of the node into my homepage. And for that, I used ...
0
votes
1answer
23 views

Accessing contents of a node id not working in .theme file

I have a page(node) with a certain ID. On the front page, I want to pull a field called field_image1 and field_link1. To do that I added the following to my themename.theme: function ...
0
votes
1answer
24 views

How do I manipulate a variable's property in Twig?

I want to add classes to a link render element that's a property of the {{content}} variable in my template. I can do this: {% set link = content.my_link %} {% set link = link|merge({ '#attributes': ...
1
vote
1answer
25 views

How to get rid of large classes with numbers from views?

Which is the purpose of classes like that one: class="js-view-dom-id-0fc70eec09ba01f6b7c7867ee7e19f7dcec1ee8b64de9dc8b791865caf299ec7" It's safe to change this class from twig templates? Thanks.
1
vote
1answer
172 views

Hide/remove js-view-dom-id in just one specific view

I found, that the div with the id "js-view-dom-id" comes from views-view.html.twig. As I want to render one view output without any of Drupals HTML markup, I already hunted down the contextual links, ...
1
vote
2answers
138 views

Cannot print page title in page.html.twig

The following line in page.html.twig does not print the page title: <h1>{{ title }}</h1> The page title outputs using the Page title block, but not this piece of template code. I found ...
1
vote
0answers
29 views

Add CSS class to entity reference (taxonomy type) rendered as a field in a node

This is my first question on the forum. I am currently developing a site (Drupal 8.8.1). I am developing it in a sub directory on the server and not using Drush, the server belongs to a large academic ...
-2
votes
1answer
33 views

Can we get the title by node ID in a template file?

Is it possible to retrieve the title by node ID, based on the interface language. I found drupal_url('/node/101', {absolute: true}). I wish to have a similar function that returns a title passing a ...
0
votes
0answers
108 views

how to get translated content in twig [views.view.unformatted]?

I am trying to get translated node title in my custom views-view-unformatted twig file. Here is the way I am retrieving my node title in twig file <div class="col-md-6 title"> {% for row ...
0
votes
0answers
24 views

Finding better solution for merge the multiple menu

I have merge two menu programmatically. I have tried with code which is listed below. After using this code it was slower my site and increase large amount of queries passed while every page load. I ...
0
votes
0answers
20 views

Skip form steps

I have created a drupal multistep webform and for smooth page transitions and better server load, etc i am using the module webform_ajax. On my webform i am using a progressbar which is similar to ...
1
vote
1answer
34 views

Conditionally display field based on comparison to other field

I have a content type Event that has a startdate (field_eventdate) and an optional enddate (field_eventend). Although it's optional, the enddate is often filled in by the users with the same date as ...
0
votes
1answer
172 views

How to override Breadcrumb theme template?

I have a custom theme that has base theme: classy setting in the mytheme.info.yml file. When we enable twig debugging locally, we find that the <!-- BEGIN OUTPUT from 'themes/custom/mytheme/...
0
votes
2answers
3k views

Twig LoaderError: Template is not defined

When I try to edit a page to upload 2 documents, I get an error. Procedure: I edit the node, upload the first document. Then I insert a new field to upload the second document. However, the second ...
-1
votes
2answers
52 views

Convert machine to human readable node type on page--node--add.html.twig (twig template variables)

I tried to create a variable on hook_preprocess_page to achieve it, but I'm only getting the machine readable name so far. $variables['node_type'] = FALSE; if ($current_path = \Drupal::service('path....

1
6 7
8
9 10
209