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

How can I get the value of the field_percentage field?

I'm trying to create a custom template for the paragraph-progress-bar component. The component I created has 2 fields: title (field_title) and percentage (field_percentage, integer field limited from ...
4
votes
2answers
898 views

Get paragraph delta/weight in template

I have defined a paragraph type that has a text field and an image field. At the moment the twig template is something like this <div class='paragraph_wrapper'> <div class='text-container'&...
1
vote
1answer
1k views

Schema.org itemprop=“url” inside anchor object (link)

I'm trying to use the preprocess function to change the default outpot of links <a href> to include Schema.org's itemprop="url" inside the anchor object, as well as adding a <span itemprop="...
0
votes
1answer
671 views

printing an entity reference field in a special display mode

I have an entity reference field. The referenced entity has multiple display modes. I'd like to print this field 2 two times in a template, with 2 different display modes like so: {{ content....
0
votes
1answer
658 views

Rate module thumbs up / down widget with button

I am using rate module to count likes and dislikes. Here I am using Thumbs up / down widget. My question is that how can I show a button below thumbs up and dislike button below thumbs down. In the ...
0
votes
1answer
35 views

Attempting to merge in an array of items into Twig classes

I have a Twig template where I'd like to merge in an array of items as classes. So far I have this code: {% set classes = [ 'media', 'media--type-' ~ media.bundle()|clean_class, not media....
1
vote
1answer
36 views

Is it possible to dynamically select between two different template files for the same content type?

We are rolling out changes on a content type with a new theme and field structures for existing content. Is it possible to dynamically select one of two template files for a content type? For example, ...
2
votes
1answer
562 views

ajax button doesnt fire callback function

I need to put some ajax buttons on each row of table. My theme looks like this: /** * Implements hook_theme(). */ function application_wizard_theme($existing, $type, $theme, $path) { return ...
2
votes
1answer
426 views

How can I load CSS files located outside the web root from within a custom module?

I need to store my css files at a location outside Drupal's path (e.g. /srv/assets/css/my_site/general.css). I attempt to achieve this using drupal_add_css but the browser loads them from: http://www....
0
votes
3answers
782 views

How do I theme the contact form?

I am trying to create a contact form for users with username, email, message, and submission button, but I want to customize the structure of the form. Where do I get the structure of the form to ...
0
votes
6answers
8k views

How can I display site logo, name and slogan?

how can i show site logo, name and slogan Separately in custom area in my site theme, I now use this code to display theme, buts this code don't allow me to edit each of them Separately. {{ page....
-2
votes
0answers
31 views

How to add an icon to a drupal text field

I am styling a drupal 8 website. I have created a new content type called course and trying to style its fields. I want to add an icon inline to a text field. Is there a way to do that using a plugin ...
0
votes
1answer
513 views

Render block via twig template

I have programmatically created a block. In my module folder I added all suggested templates in a templates folder(mymodule/templates/suggestedtemplatename.html.twig). However the block is not using ...
1
vote
2answers
446 views

How do I split a contact form into multiple pages?

I have a huge form that's way too large for a single page. I would like to split this form up into a few separate pages. What are my options? Edit: Still haven't figured out how to do this with ...
1
vote
1answer
85 views

Removing HTML rendered for Block Regions

In my custom Drupal 8 theme, for all regions of my page, there is HTML looking like: <div class="block-region-xxxx"></div> where xxxx is the region name. There are also empty 's ...
1
vote
1answer
659 views

How to render a Commerce pane programmatically?

I've the following code: $panes = commerce_checkout_panes(); $payment_pane = $panes['commerce_payment']; which loads one of Commerce pane which contains the array like: array (size=15) 'title' =&...
1
vote
3answers
4k views

Cannot print View title in View template

How can I print the title of my view in views-view.html.twig? I have tried both {{ title }} and {{ label }} but neither work. You can see the title is set in the View, and the template is using {{ ...
0
votes
1answer
453 views

Login page when using a Zen's sub theme

I've created a website based on a Drupal 7 Zen subtheme and now I would like to create a login page for the administrator. When I navigate to http://mysite.com/?q=user, I return to the main page as ...
0
votes
1answer
382 views

How do I override /theme/custom twig in my module to render input fields?

I have a module that is building a form. I want to theme the form using twig within my module so it does not interfere with my theme/custom twigs. My buildForm function is: public function buildForm(...
0
votes
0answers
23 views

How selectively print the content of region.html.twig

I'm trying to modify the html of region.html.twig I've used a hook to override the suggestion: function my_theme_theme_suggestions_region_alter(array &$suggestions, array $variables) { if($...
3
votes
2answers
10k views

How do I generate PDF content from a node?

We are looking for a way to convert the Drupal pages into PDF on click of a button for D8. Initially we thought we could use Print Module, but that only has a D7 version. How do you create a button ...
0
votes
1answer
10 views

Twig: Display media library reference user image at particular resolution with alt tag (on /user/1231 page)

On our user page (/user/12345) we want to change the profile image field to be a media library reference field instead. I've created for the user object a new field called field_profile_image that is ...
44
votes
11answers
77k views

How to get the valid URL of a Link field from within a Twig template?

I have a Link field named field_my_link (machine name). Within a Twig template I can get the link's URL value with this: {{ node.field_my_link.uri }} If inside the Link's URL there is an external ...
1
vote
1answer
358 views

Render array doesn't render children

I can't add a form to a node. Using the following code, the generated HTML show only the node. If I return $form, the form is rendered correctly. What is my mistake ? function hook_menu() { $items['...
2
votes
0answers
114 views

Search a URL list, return JSON values into a dynamically generated table

I am looking for a Drupal Service or a Module (or a link to a working example) of this arrangement: There's a Search form. Placing and submitting the search will make a REST call for certain values ...
1
vote
1answer
1k views

Add JS to specific pages AFTER all other JS

I am working with JSON to theme Google Maps in the api v3. I have my custom JSON script as an external JS file, and I am currently referencing it in html.tpl.php after the other scripts are loaded. ...
1
vote
1answer
304 views

Responsive Views-Slideshow Json Cycle working good in Chrome not in IE or mozilla [closed]

In drupal I AT themes, views with slideshow of json2 and cycle plugin. I set the options for the plugin like this : Make views slideshow responsive - remove inline styles height auto , width auto ...
1
vote
1answer
1k views

How to apply js and css to ajax loaded content?

When content get loaded through ajax, neither theme.css or js get applied. Below is code snippet, controller $twig = \Drupal::service('twig'); $twigFilePath = drupal_get_path('module', '...
1
vote
1answer
80 views

How to prevent my ZURB theme from stripping out part of the JSON LD element?

I use ZURB theme and following I post the code of my template.php file. My problem is, that type="application/ld+json" in <script type="application/ld+json"> gets stripped out so it is rendered ...
0
votes
3answers
383 views

Passing global variables to alter hooks

The problem I have is that it seems that I can use global variable created inside another module, only if I use it inside callback function. I successfully tested it by inserting code inside existing ...
1
vote
1answer
565 views

How do I render a field template?

I have problems with rendering twig templates inside my block theme. Is it possible to display default template for a field that I've fetched with entity manage query? I've got a custom carousel ...
0
votes
1answer
425 views

How do I print an image field value in views-view.html.twig?

It seems I'm able to print text field values with {{ view.field.field_example.getvalue(view.result[0]) }}, but this same method doesn't work for image fields. Please help.
0
votes
2answers
648 views

How to display all children on parent node for custom content type?

I have a custom content type, let's call it 'parent'. I have another custom content type, let's call it 'child'. I created a template file where I can display the 'parent' content type fields any ...
1
vote
1answer
463 views

Form is not being rendered in template file

I have tried drupal_render,drupal_get_form etc for rendering the form,but the form is not being rendered. Is there any error in code or else what else should i add to the code so that it works. ...
1
vote
0answers
467 views

Drupal + nginx no CSS

I'm having issues with drupal on nginx. CSS is not displaying but the website is working and I have no clue why this is happening. I have installed nginx + php70-fpm on Mac OS El Capitan and I am ...
18
votes
9answers
45k views

Create template file for views block

There is a lot about theming custom blocks, but what about blocks created by views? My views block has id: block-views-posts-listing-block, I try many ways for naming template file, ex: block--block-...
5
votes
2answers
2k views

How do I serve up a themed 500 error response page?

Has anyone developed a custom themed page for 500 errors on a Drupal 8 site? There is no maintenance offline template equivalent, and core out of the box simply delivers an unstyled stack trace. We've ...
0
votes
2answers
50 views

How can I output the absolute URL as link text for internal links on link fields?

When using a link field without a link text and just with the URL, Drupal 8/9 outputs the relative path as the link text for internal links. How can I change that to either output the absolute URL or (...
1
vote
1answer
758 views

How do I add icons to taxonomy terms?

I have a sample site running Drupal 8.1.x, I want to add icons to the taxonomy term. Example. I have a term called Animals with the following list in it Cats Dogs Fish i want to assign an icon ...
0
votes
1answer
665 views

Variable in html.tpl.php

This seemingly simple task proved more difficult than I imagined.. I'm trying to get a variable from themename_preprocess_html to my html.tpl.php. The code I have in my template.php file: <?php ...
1
vote
1answer
37 views

How to add “rel” attributes to all external links throughout the website?

I'm trying to add attributes for external links such as the rel="noopener noreferrer" for all the external links where target="_blank". I've tried using modules such as the ...
1
vote
1answer
860 views

Render Custom Menu Block from Menu Tree Array of Links Programmatically

Here's what I have: A custom menu (side nav) that mimics the main/secondary menu tree which shows the entire subtree of the root menu item (Dine, Play, Stay) you're under. This sidenav can be ...
0
votes
1answer
573 views

Update theme table using callback function in Ajax

I have two elements in my form: a select and a table element. Everytime onchange event is triggered on select element, I want to update the values in my table. I want to do query and change the values ...
1
vote
1answer
624 views

programmatically create one bean block to the default theme

I am trying to programmatically create beans in a custom module using entity_metadata_wrapper. This is creating a bean for each installed theme. (In Drupal 7) Is there a way I can create only one ...
0
votes
2answers
446 views

custom js in bootstrap sub-theme is loaded, works in console, but doesn't actually work in browser

I have a bootstrap subtheme with scripts[] = script.js in the .info file. When I go to the site and view html source of the page I can see that drupal is including the file <script src="http://...
1
vote
1answer
411 views

Cannot access responsive image sources from Twig

In Twig I am unable to retrieve the file source for each responsive image style on a ImageItem. How should I be getting this information?
0
votes
1answer
619 views

Add radio buttons and text field together to theme-settings.php

I want to integrate a CSS switcher into my theme, but without the Color module. So I want a radio button list, (or a select list, or dropdown, doesn't really matter), with a list of different styles, ...
0
votes
1answer
17 views

When using a grouping field in an HTML list, is there a way to determine the group/loop number of the current content being rendered?

I want to be able to determine what group number is currently being processed to that I can treat the output of the first group differently than subsequent groups. Unlike rows, I do not see a way to ...
0
votes
0answers
13 views

Suggested template in layout builder is not being picked up

I am using Layout Builder and I would like to tweak template file a bit. I can see suggestions here: But although I added file layout-twocol-section--node-npx-training-teaser2.html.twig in my theme ...
1
vote
2answers
1k views

Display HTML field

I am using Views Database Connector to display safe data from external database in Drupal 8 within views. Some of the fields include simple html like a list which views encodes in html entities. I am ...