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
11 views

How do I change the width of a mega slider?

I am using Drupal 7.x. I am using the popular theme is porto. https://i.stack.imgur.com/Kmhok.png Porto comes with a Mega Slider component. And that is what I am using here. I am using the Mega ...
0
votes
1answer
38 views

Print image URL with image style

I would like to print an image URL with an image-style. This doesn't work, since I don't have a ".value"-value for the image: How to find image style URL from within twig template? Is there anything ...
0
votes
0answers
22 views

How to include book traversal links on a custom twig template page

I use the Book module to create books with chapters. When I use the default twig template node.html.twig to display a book chapter, a section titled "Book traversal links" is included, with links to ...
0
votes
2answers
47 views

Change html tag in template file tpl

I have this template file for a view: views-view--ir-news--page.tpl.php But right now, I need to use Google AMP only for this view (Machine name: ir_news) What I want to know is if something like ...
1
vote
1answer
29 views

Why is Twig not outputting this correctly?

I have function hook_theme_preprocess(array &$variables, $hook) { $variables['bla'] = ' AA <strong> BB </strong> CC '; } In my template I have: {{ bla }} The problem is, in ...
1
vote
1answer
126 views

Get all nodes of a specific content type and print the data of each node inside page.html.twig

I have a content type (Flower) with two fields: Name and Color. In my-theme/templates/page.html.twig, I want to print the name and the color of each flower. <div id="page"> {% for flower ...
1
vote
1answer
37 views

How to pass contextual id value from one view page to another through Drupal menuing system

I use a view to display a list of books. The view has three pages: /books/title, /books/date, and /books/popularity. The pages are essentially the same with different sort criteria. The pages use a ...
0
votes
0answers
83 views

Pass variable from custom module to twig template

How can I pass a variable from my custom module to a twig field template? my field template is the "field--node--field-webform--parliament-visit.html.twig" and my module is named as "custommodule" ...
1
vote
1answer
38 views

Create one-off page with specific fields and template

I'm new to Drupal and trying to add a single new page to an existing Drupal website. It has its own design (with its own css) and its own content requirements separate from the rest of the site. I'd ...
0
votes
1answer
18 views

Rendered markup different than template markup

I am using drupal 7, and the bootstrap base theme to make a simple theme for a website I am working on. I am having issues with Drupal forcefully changing my html5 hierarchy and it's causing the site ...
0
votes
1answer
195 views

Add class to {{ link }} twig attribute

I'm trying to apply a button class to the {{ link }} attribute in code below. <span{{attributes}}><a class="usa-button"{{ link }}</span> It displays correctly however the markup is ...
0
votes
3answers
51 views

Using MYTHEME_page_attachment_alter does not alter the favicon

Based on other similar stackexchange questions and documentation, I've implemented the following in the MYTHEME_page_attachment_alter function in MYTHEME.theme file to change the favicon based on the ...
0
votes
1answer
12 views

main menu disappears only on home page

I have a site online engcorrect.net and for some reason my menu on my homepage disappears. On all other pages, it shows. The weird thing is that on my localhost (local machine) it shows correctly but ...
0
votes
1answer
39 views

How to tell if a menu link is route:<nolink> or not?

Trying to theme a menu in Drupal 8, running into a case where we need to add classes on certain links. In the case of a menu link that is route:<nolink> we need to not add any class at all. ...
-1
votes
1answer
55 views

How to rewrite the field of a view with Twig

I created a view with the machine name cgv_product. This view contains the fields "Product Name" and "Custom Text". In the "Custom Text" field, the {{ name }} Twig code is available to display the ...
2
votes
2answers
63 views

Is it possible autoload PHP classes in themes?

Does the namespace, class name and naming convention work like it does for modules? These links don't seem to mention it: https://www.drupal.org/docs/develop/standards/psr-4-namespaces-and-...
0
votes
0answers
35 views

how drupal render api works?

I'am trying to deeply understand the drupal rendering logic, so I have create a custom module to grasp the rending logic, then I draw this diagram , wich needs a review to be sure that I understand ...
0
votes
1answer
49 views

Contextual filter in URL via Twig [duplicate]

Does somebody of you know how to build a link as described in #9 in https://www.drupal.org/project/views_contextual_filter_query/issues/2686467#comment-10983075 I tried it this way <a href="node/{...
1
vote
0answers
54 views

Trouble Hiding Regions When Blocks Are Empty

Having trouble seeing why my regions render when I think they shouldn't... page.html.twig: {% if page.region %} {{ page.region }} {% endif %} region.html.twig: {% if content %} <div id="" ...
0
votes
0answers
45 views

How to add class to a file link in Twig

I'm trying to add a button class to an internal file URL. The field itself is a normal file field type. Below is the twig code that I have tried to use with no success. I'm also using this code in a ...
0
votes
1answer
78 views

How can I render HTML tags in a variable in a twig template?

I have a variable in my twig template called description. The variable is a string with an html em tag in it. When I go to the webpage to view the field, the html em tags are stripped out of the ...
0
votes
1answer
53 views

Add site branding to external site

Maybe I'm asking the wrong questions on google, but I can't seem to find a solution to what I'm trying to accomplish. We've created a Drupal 8 site and we need to add the existing header and footer ...
1
vote
1answer
289 views

How to access raw data in twig template using views table format

I use a table format view to display a list of articles article-list using draggable views to allow editors to order the list. I customize the content of rows depending on a boolean field is_header ...
0
votes
2answers
40 views

How to reuse the same custom template in Ajax callback

I am currently trying to display a list of nodes with a custom form containing taxonomy dropdowns (placed above node list) to filter out the contents. Now, on page load all content is displaying well ...
0
votes
0answers
18 views

How do I name the comment.tpl.php file to use it in my own theme?

I have copied comment.tpl.php from mytheme/modules/comment into root/sites/all/themes/mytheme/templates. What should I name it to override the core template? The form ID is places-to-go-entry. I ...
1
vote
2answers
90 views

Theme CSS libraries always loaded after module libraries

My custom theme uses Bootstrap, which I'd obviously like to load before any module CSS libraries, but Drupal ignores any kind of ordering for themes, and Bootstrap CSS styles appear as @import in a &...
0
votes
1answer
20 views

Show Description Field on Individual Webform Submission Result

I would like to include the description field when viewing individual webform submissions for each component. The standard webform individual submission display shows the label and the answer, but the ...
0
votes
1answer
360 views

How to add query parameters in twig using path()?

I am following the code snippet provided here {# Link to frontpage view. #} <a href="{{ path('view.frontpage.page_1') }}">{{ 'View all content'|t }}</a> {# Link to user entity/profile ...
0
votes
0answers
28 views

What is the right way to enable contextual links on a field template with custom code?

I'm trying to figure out if there a way to enable contextual-links on a field twig template using custom code. I have an entity reference field and created a field templatefield--field-featured-page....
1
vote
1answer
34 views

Print Preprocessed username Field Value in User Template

$account->getDisplayName() Bypasses "username" Field Preprocessing in User Template? I am trying to print the value of the username field of the user account in a user--custom.html.twig file. ...
0
votes
0answers
18 views

Override for Simplenews is not working

I tried to follow the instructions for custom newsletter theme and it told me to copy and paste simplenews-newsletter-body.html.twig into my custom theme folder. But on sending test emails it doesnt ...
-2
votes
1answer
16 views

Different formatter's field by file extension

I have Drupal 7 and a file field and users can upload pdf, office documents and image. For pdf i have pdf.js formatter, office doc's have simple link to download and image show by fancybox plugin. I ...
0
votes
0answers
39 views

Why does library-extend not find the additional library?

I am using the Tara theme, which has a library global-styling. I have created a sub-theme of it, called Art. I want to extend the original library. My setup is as follows: In themes/custom/art/art....
0
votes
1answer
15 views

Javascript is not loading in Zen custom theme

I'm not able to get my custom theme to run javascript on all pages. My code is as follows. My Custom module is enabled, and Component Libraries module is installed and enabled. custom_theme.Libraries....
1
vote
2answers
56 views

How to print link text in twig?

I've attached file to a node with Media module. I have custom templates/file/file-link.html.twig file, which is rendering the download link with {{ link }} tag. {{ devel_dump(link) }} outputs this: ...
0
votes
1answer
29 views

Use custom variable in html.tpl.php for critical css

I have built my current theme in my D7 site upon the Foundation theme, and with that comes a LOT of unused CSS that gives me a low score in Pagespeed Insights. I have tried different things, among ...
0
votes
1answer
54 views

Get Absolute url using hook_preprocess_node

We are attempting to change the $variables['url'] from a relative to absolute URL within the mymodule_preprocess_node() hook. The $variables['url'] is displayed as a <a> element within our node--...
0
votes
1answer
115 views

Output field with double quotes in twig

We have a field, field_text, that we are displaying on the Basic Page content type. It needs to display with double quotes " using twig template. We tried the following below, but it is displaying ...
0
votes
1answer
71 views

Pass a value from a block preprocess hook to a twig template that inserts that block

I use the D8 book module to manage magazines and their articles. In the node--magazine.html.twig template for a magazine, I use the built-in book_navigation block to add a table of contents. This is ...
0
votes
1answer
28 views

Remove left sidebar shopping cart

I know the shopping cart is generated by the view shopping cart form. But how do I remove the shopping cart block on left sidebar of the home page and still maintain the the view on /cart page? I have ...
1
vote
2answers
67 views

Trying to access and print the values from the fields within Paragraph

I'm having trouble trying to access and print the values manually within the Paragraph. This is a snippet from the paragraph field template I have created. I wanted to access and print values manually ...
1
vote
1answer
76 views

How to display the views page title in a custom fieldable block

Goal: To create a custom fieldable block as available out of the box in D8, which also shows the page title of a a views page, if the page it is displayed on is a views page. I created a custom block ...
0
votes
1answer
43 views

Howto theme list of nodes as item-list?

I want to show a block with related nodes. The function getRelatedArticles() is a complex one and I can't build it with views. Is it possible to use the method viewMultiple() and output the list as ...
0
votes
0answers
17 views

No option to place blocks in custom layout

I'm trying to build a custom layout for my site. I used the layouts in the layout_discovery module as an example but they're not behaving the way I expect. Here's what's in my mytheme.layouts.yml ...
0
votes
1answer
13 views

theme style.css is not loading for custom theme

I am trying to learn Drupal 8 theme development. I am trying to create basic theme My Folder structure |-themes | |-custom | | |-contra | | | |-css | | | | |-style.css | | | |-...
0
votes
1answer
198 views

How to retrieve value of hidden field in twig?

How to retrieve value of hidden field in twig? PFB screenshot: I am able to retrieve value of "Partition Count" field when not disabled. But not able to retrieve it's value when disabled. Exact ...
2
votes
0answers
79 views

Contextual links in block disabled when using Twig Tweak and UUID

In my taxonomy-term--NAME.html.twig I use a reference field to load a 'block_content'. {% for item in term.field_blocks %} {% set uuid = item.entity.uuid.value %} {{ drupal_block('block_content:'...
0
votes
1answer
45 views

How to override theme for quicktabs which actually renders a view

In D8, I want to display a view through quicktabs. For this, at first I have created a view file and call the view through QT. The view is displays well through QT. Now, I want to change the look &...
0
votes
0answers
26 views

Default value for image field not accessible [duplicate]

I have added a field to content types so that users can upload a custom background image based on content type. This is a Drupal 8 site. The field is set as required and has a default image uploaded ...
0
votes
2answers
63 views

Add HTML Tags for all the site pages

I was searching around but with no clear solution for me! I would like to add the below HTML code for all my Drupal 8 website pages: <meta name="viewport" content="width=device-width, user-...