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
2 votes
1 answer
1k views

How can I add animation/fade to modal/dialogue boxes?

The current state of a modal/dialog opening in Drupal 8 (and 7 for that matter) is pretty clunky from a user experience perspect. Leveraging some type of animation/fade would really enhance the ...
1 vote
1 answer
718 views

How can show pdf preview first image?

Hope you can help me. I use drupal 8. I want pdf preview like this http://prntscr.com/j08ljo. Need uploud pdf file in node and showing just first image in front page. I check use module pdfpreview ...
1 vote
1 answer
123 views

How do I programatically change a webform's element type?

I am using a webform element 'select_other' in the webform. We got a requirement that the Other field should only appear if certain conditions are satisfied. I already have a Webform Handler In place, ...
0 votes
1 answer
628 views

How to theme webform in D6?

I've got a website with a custom theme who was developed by an external group. I would like to custom the webform appearance. In my form, there are grid fields. And these grid fields need to have a ...
0 votes
2 answers
454 views

Views Pager Add rel="nofollow to ALL Pager Links

In Drupal 7 I am trying to add rel="nofollow" to ALL of the pager links in views. The closest I have got is to add the nofollow to next links, but I want it to include previous pages as well as "First"...
0 votes
2 answers
522 views

Use twig to style a specific block (unformated list)

I have a block showing a unformated List of fields. Now I would like to use twig to style that block. I am able to use block--views-block--blockname-block.html.twig to do the outer styling. But I ...
0 votes
1 answer
1k views

How to get access all images of custom directory in twig template?

I intend to create a slideshow in front page of my theme to show all images in custom directory, I try to use file_scan_directory and drupal_get_path in below codes to get any non static images path ...
0 votes
2 answers
544 views

Is there a reliable way to show Drupal messages from JavaScript?

I need to show status messages (the kind typically shown by drupal_set_message()) in my module's JavaScript code. How can I do this reliably, such that the theme and placement of the messages remains ...
0 votes
0 answers
17 views

get view field image src url in view-fields twig file

I have a image in a view and image is showing in complete tag. basically wamt to use image as background-image style. So I want image URL rather complete image tag. I tried some code but none worked ...
2 votes
1 answer
596 views

How to group-by fields in view AND control output via template file

I 'm hitting a brick wall on this one, so trying to reach out for help. I did try to research this but could not find anything helpful. What I have: I have a content type of 'courses', which have ...
-3 votes
1 answer
24 views

Avoid adding custom CSS to a node editing form?

Situation custom module adding styles don't add styles to node editing form How to avoid adding the style to the editing forms? function crossfade_page_attachments(array &$page) { $page['#...
1 vote
2 answers
1k views

Inline Template with Render Array in #context

I'm using the https://api.drupal.org/InlineTemplate to render a string with a variable, and that variable is itself another theme function. My reading of the documentation is that this is supported;...
-2 votes
1 answer
53 views

Get MenuLinkContent object values

get title and link of a menu link object in. I am trying to get title and link of a MenuLinkContent object and below is my code. I want to get title and link value. How I can get the title and Link ...
1 vote
1 answer
658 views

block view is not displaying

This problem starts with the subtheme. I am using drupal 7 with a subtheme based on omega 3.1. For some reason node title and admin tabs are displaying only on the home page and two basic pages, ...
1 vote
2 answers
770 views

Dynamically Theme Boolean Fields

I am trying to dynamically display boolean fields into columns based on their value. So for instance these 10 boolean fields on my node, if marked 1, I want it to theme it so that they show up in a ...
1 vote
1 answer
1k views

Unknown drupal_view() function although Twig Tweak is installed

Acquia BLT won't let me commit some Twig. > tests:twig:lint:all Validating twig syntax for all custom modules and themes... Iterating over fileset files.twig... ERROR in ~/repos/agency/client-...
2 votes
1 answer
944 views

Overriding views fields in twig

I want to override the default views-view-fields.html.twig so that I can display specific fields in a bootstrap layout, e.g. <div class="col-sm-3">{{ fields.field_name_1 }}</div> <div ...
2 votes
2 answers
1k views

How to override a module theme function in a custom module but still allow themes to override the template file?

I'm writing a fairly simple module which allows the removal of colons from field output on a per field basis and I need to override the core field module's theme_field function in my module. I can ...
1 vote
2 answers
417 views

URL paths in optimized CSS sometimes are https instead of http

The expanded URLs inside my optimized CSS files are sometimes getting generated with https instead of http. This appears to happen randomly. Doing a cache clear, recreates the optimized CSS and ...
0 votes
1 answer
143 views

How can I find the image style source from a template file?

Why cannot I use {{ file_url(node.field_image.0.entity.uri.value) }} in a view? It does not return /drupal-8.6.1/sites/default/files/2018-10/gen9C52.tmp.jpeg as I expect.
2 votes
1 answer
813 views

How to set up path for library and include files

In Drupal 7, I am writing PHP from inside the Front Page module, say: $page = include_once "templates/page.php"; I put the "templates/page.php" under /sites/all/modules/front and Drupal complains ...
1 vote
1 answer
788 views

Implementing preprocess function for custom template

In Drupal 7, I'm creating thank you page for a custom form and have following in my mymodule.module: function mymodule_menu() { $items = array(); $items['mymodule/thank_you/%'] = array( '...
0 votes
1 answer
782 views

How do I get a list of all CSS and JS that are attached to a page?

In Drupal 8, how do I get all CSS and JS that is attached to a page? In Drupal 7, I could use drupal_add_css() or drupal_add_js() without arguments, to get an array containing a list of all the files/...
2 votes
1 answer
832 views

How do I tell Twig not to print any form field?

I am trying to theme a form in Drupal 8. This is the template that I am using which is basically from form.html.twig <form{{ attributes }}> {{ element.app_theme_settings }} {{ element.a2 }} {{ ...
3 votes
1 answer
451 views

Select an Image style depending on external/dynamic factors (theme region or other field content)

I have a Bean (bundle that generates blocks) which I display in one of 2 different theme regions. Either in the header, or the footer. This Bean contains an Imagefield, which is rendered through an ...
0 votes
1 answer
27 views

On android, keyboard comes up momentarily and then disappears when a user clicks the search field (likely due to triggering a js resize event)

Related to this: https://stackoverflow.com/questions/51493956/android-keyboard-appears-and-disappears-when-clicking-search-input We have some javascript that rearranges a couple elements in the page ...
-3 votes
0 answers
24 views

How to conditionally load JS based on User Role on Layout Builder?

I'm looking to load a couple of javascript files or functions in layout builder based upon whether someone is an admin or not. I'm not sure if this is something I should be doing in Twig or maybe in ...
0 votes
2 answers
591 views

In a template, is it possible to get the content of a block by the block ID?

I am working with some view templates in Drupal 8, and I have the block ID of another view block I want to pull into the template. Is it possible to use the block ID to get the content of a block in a ...
0 votes
1 answer
418 views

template.php hook to add variable to view

I'm trying to include the total count of a given node type into a view tpl.php file. I would like to set this variable in the template.php file, so that it is available in the tpl.php file (that way I ...
0 votes
1 answer
579 views

How do I make theme suggestions for pagers?

I am trying to create theme suggestions function for pagers in my *.theme. Is this possible in Drupal 8? If it is possible, what is wrong with the following code? Is suggestions_pager_alter the right ...
0 votes
1 answer
875 views

Disable/remove javascript

does anyone know how to disable a javascript loaded by drupal? <script src="/profiles/ncr/themes/contrib/bootstrap/js/bootstrap.js?ny8c02"></script> I tried the following in the ...
1 vote
2 answers
931 views

How to set a field value from parent template in Twig?

I have node--article--teaser.html.twig which calls image-formatter.html.twig to printout the field_image. Everything works fine except that I don't want the field_image itself to be a linked. i.e ...
0 votes
2 answers
22 views

Error with {{ page.highlighted }} while making a copy of Olivero

I am trying to learn Drupal 9 theming by copying Olivero theme into my themes folder. I copied web/core/themes/olivero to web/themes/olive and then renamed all file names containing 'olivero' to ...
0 votes
1 answer
446 views

Pass custom variable to an entity reference templete

i have the following problem in Drupal 8. In custom content type there is a field, which is a multiple entity reference to the same content type. The field is set to use custom view mode, where only ...
0 votes
1 answer
761 views

Accessing Content: Path field within views_view_unformatted TWIG template

I have a view that has the fields: Content: ID, Content: Title and Content: Path. In my views-view-module.html.twig file I can access the fields via the following: {{ item['#row']._entity.id }} {{ ...
4 votes
1 answer
362 views

Twig cache files on load-balanced setup

The Twig cache key (twig_cache_prefix) is based the modify timestamp of the Twig template file and a randomly generated key. This gives a problem with a load-balanced Drupal setup where every host has ...
1 vote
1 answer
421 views

Change mark-up with a textfield using Ajax

In a form I have a field where the user have to enter the name, after this I have to update a markup with data from an external DB using the textfield as a parameter, How can I do this or even Is this ...
0 votes
0 answers
24 views

How can I display the output of a view with no surrounding templates that can be embedded in an iframe inside another website?

I have a user contextual view which is accessed via a URL like: /user/114/my-view I want to provide the output of this view in a raw format without any surrounding page HTML so that it can be emdedded ...
2 votes
1 answer
694 views

Theme template.php functions after bootstrap

I'm trying to print a drupal menu outside drupal. In order to achieve this I ran the bootstrap as follows: drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); And I render my menu as follows: public static ...
1 vote
1 answer
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
1 answer
623 views

Pager not working when $form['table'] is called with AJAX

For a statistics page I let users select the right file in a select list. After that I generate a table with stats. This table also has a pager (that worked without the ajax part). Now I did ...
3 votes
2 answers
648 views

Link tags in template file auto closing.

I’m having an issue wrapping a link around some output in a template file. I have the right template file; and I can put text like ‘start here’ and ‘end here’ and it prints out where I want the ‘a ...
0 votes
2 answers
821 views

Template override doesn't work

I am trying to develop a Drupal 8 module in which I have to override the html.html.twig template. The idea is that I do not want any of the default html.html.twig template returned instead I only want ...
1 vote
2 answers
3k views

How do I compare a date field with the current time in a twig template?

I have a date field on a node – set to a custom date format (c which is ISO) in the Manage Display. I have a twig template checking to see if that date field comes before today, in which is should ...
2 votes
1 answer
543 views

Views Grouping field:Add Ordered class to Grouping row

I use Views and Grouping field to integrate my data. But i need each grouping row ordered. I want to override the views-view-grouping.tpl.php, and change the "view-grouping" class to "view-grouping-1"...
1 vote
1 answer
461 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 ...
-1 votes
3 answers
5k views

How to add class to image tag in Twig template? [duplicate]

How can I add a CSS class to an <img> tag by using a template file if output looks like this: <!-- BEGIN OUTPUT from 'themes/contrib/bootstrap/templates/system/image.html.twig' --> <...
0 votes
1 answer
414 views

sort comments descending programmatically

I want to sort all comment descending programmatically, I found this Comments sorted by oldest first but I dont want use those modules or views solution. anybody know how can I sort comment ...
3 votes
2 answers
479 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
1 answer
495 views

Theme UberCart catalog page to use custom html

Working with Ubercart 3.x on Drupal 7. I want to theme the /catalog/1 page, where it shows my products. I want to use completely custom html that has divs nested with tables nested with divs. I ...

1
2 3 4 5
214