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
1
vote
0answers
42 views

Render blocks of custom type

Either I'm stupid or I can't search. Sorry if this is a duplicate, but I can't find any answer to my problem. I made a custom block type in admin panel, named it content_under_listing, and then I made ...
0
votes
0answers
22 views

twig template to fetch details of linked nodes [duplicate]

I have a content page say content type "spl content" which has few related pages(added using field entity reference). when i create page in admin I can link multiple pages to my page using entity ...
2
votes
1answer
36 views

How to add highlighting to exposed views_autocomplete_filter in Drupal 8

Is there a way (a hook perhaps) that would allow me to modify the autocomplete fields returned by an exposed views_autocomplete_filter field? I'd like to style the text typed into the field ...
-3
votes
2answers
214 views

How can I prevent memory size exhaustion when dumping variables in Twig? [duplicate]

hello everyone i have a problem with kint , in my twig page i want to listing all variables contains int 'content' variable to make some logic on it , but the page can't loaded because the big pip ...
1
vote
1answer
85 views

How to get node title using this query on template?

Im building a custom filter in Drupal 8 based on some queries. I got this already, here im filtering by values on body: $query = db_select('node__body', 'n') ->fields('...
0
votes
1answer
30 views

Twig embedding and field object

I'm using Radix and trying to create a Botstrap carousel component with no luck. This is the code so far. Kint shows me that media object is there with its multiple fields but nothing is rendered. ...
0
votes
1answer
70 views

Can we pass argument to a form from a Twig template

I have a form that accepts a custom argument sourceid public function buildForm(array $form, FormStateInterface $form_state, $sourceid = NULL) Now, this form is displayed in a twig template ...
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
137 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
300 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
346 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
71 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
48 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
84 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
40 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
57 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
186 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
33 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
345 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
72 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
174 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
59 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
80 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
53 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
47 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
153 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
30 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
30 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
42 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
46 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
122 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
50 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
62 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
32 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
204 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
74 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
33 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
22 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
22 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.
0
votes
1answer
146 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
107 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
28 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
31 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 ...

1
5 6
7
8 9
208