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
2answers
2k views

drupal 7 template suggestions based on path alias

I am using this function on a D7 site to template based on url alias and everything works except when a page has a dash in it. For example mysite.com/test-page doesn't work. I tried page--test-page....
2
votes
2answers
608 views

Show image filenames on Drupal 7 node

I upload multiple images to a node using one content type image field. I need to render the file name for each image under the image when viewing the node, all I get at the moment is just a page of ...
2
votes
1answer
5k views

Access field value in template_preprocess_views_view_field function?

I have a client with a Drupal 8 site who prefers curly quotes to straight quotes. I have successfully made this change for node titles using a regex replacement in template_preprocess_page_title. Now ...
2
votes
2answers
1k views

Message + add class

i need to add another class to message div. That class must be the name of the module that creates the message. Example: A new mail is added via "Simple suscription" module. Then the message div ...
2
votes
1answer
4k views

How to check for view mode in twig template?

We have one field (field_tabs) that is used on Basic and Article content type. On the Basic page content type, it has a custom view mode (view_mode_vertical) and on the Article content type it has a ...
2
votes
2answers
894 views

Redirect basic page to external url when visiting page

I'm attempting to provide a field to users to enable them to enter an external url. If they enter a url I would like that basic page to redirect to the url the user provided instead of actually ...
1
vote
1answer
122 views

How to add a theme preprocess function for published state?

I want to create a body class for the published state of a node. I found some suggestions below for Drupal 7, but this code is not working for my Drupal 8 theme. Add class based on published state ...
1
vote
1answer
162 views

Reason for adding .value to access node id?

I was trying to access node id in twig. After debugging for a while I found that node.nid was holding the value I wanted. However, when I tried to render using that variable it didn't print anything. ...
1
vote
3answers
345 views

Body Summary field showing literal ampersand character code in view

I have a Drupal 8 site where we've created a view, and decided to use the summary field instead of the trimmed body field, so that we could have more control over it. However, I got a bug report ...
1
vote
1answer
199 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-...
1
vote
2answers
131 views

Can we write php conditions in view field templates?

My view fields are as like shown in screenshot, for each row I need to add comment link,revision link ,edit link, voting icons and topic terms etc And I have large number of views which will share all ...
1
vote
2answers
244 views

How to show/hide the prefix/suffix of fields in node templates?

I previously asked a question about hiding the prefix/suffix in fields template here, now I want to understand how can I programmatically hide the prefix or suffix of numeric fields in nodes templates ...
1
vote
2answers
1k views

Passing variables to a block template [duplicate]

I am using the following code, but it doesn't work. drupal_block.module function custom_blocks_theme($existing, $type, $theme, $path) { return [ 'custom_blocks__front_apps' => [ '...
1
vote
2answers
416 views

How can I print subparagraphs?

I have a content type with a paragraph field. That paragraph field has two paragraph fields which I will refer to as subparagraphs. I want to print one of the two subparagraphs depending on the flag ...
1
vote
2answers
367 views

How to output view content as grid in custom template?

I have created a view for content type xyz with fields F1, F2,F3,F4. I open the group "advanced", clicked on "Theme: Information". There are couple of template files, that are used by view. I ...
1
vote
1answer
56 views

Check if referenced field exists in commerce product display

I have to render different types of product (with different fields combinations) in a generic product display tpl file. I created an array with all possible field names (they all are referenced ...
1
vote
1answer
1k views

libraries-override not working

I'm trying to figure out how I can remove the default css libraries of Drupal 8 on the theme I'm working on. I tried using libraries-override: to remove a specific CSS but it doesn't seem to be ...
1
vote
1answer
39 views

How to correctly get the twig value

I have the following response using kint. How can I correctly get the value of the title. I tried stream.node_title[0]['#context'].output but getting null result.
1
vote
1answer
1k views

How do I output the link to the content?

In a view, I've got a field set up to output the link to the content. I'm not sure how to reference it in my views-view-fields.html.twig file. I'm referencing all of the other fields values properly ...
1
vote
2answers
2k views

How to add attributes to a specific field's image

subtheme/templates/image/image.html.twig controls the style of every image at a website is there a way to overwrite the image.html.twig for a given field let's call it field--profile--field-...
1
vote
1answer
61 views

Is there a means for telling which module or template files generated a block?

I am trying to find out what code generated a faulty looking devel block and want to know if there is a module that can tell where a block was generated or some other means. Is there a module for ...
1
vote
3answers
3k views

Drupal 7 how can I alter page content generated with module?

I have one module: function MYMODULE_menu() { $items = array(); $items['mymodule'] = array( 'title' => t('My Module'), 'page callback' => 'MYMODULE_view', 'access ...
1
vote
2answers
342 views

Custom module's output is not wrapped in the site theme

I've put together my first Drupal 7 custom module. I've implemented hook_menu() to get it to path correctly, but I cannot seem to get the output wrapped in the page tpl. I can visit domain.com/...
1
vote
2answers
201 views

Maintenance page being rendered as an entire page load after the main page load

I've noticed that I've got a maintenance page being rendered in its entire HTML markup format after my pages. The site is not in maintenance mode, and this is not intentional behaviour. I'm trying to ...
1
vote
1answer
3k views

adding twig variable in html.html.twig from module

I'm looking to add a twig variable, which is set in a module, and render it in the html.html.twig template file for my theme. In my module file I use the hook_preprocess_html() function where I ...
1
vote
1answer
89 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. ...
1
vote
1answer
156 views

Wrong User Image Display - Weird Twig Cache?

I'm having a weird issue with incorrect user images being displayed and it seems to be a caching issue or perhaps I am passing the user image incorrectly to my template. Problem: If I login to a ...
1
vote
2answers
306 views

Taxonomy terms manipulation on node.tpl.php

I wanted to print taxonomy terms on my custom node-mytype.tpl.php but what I want is not to print all the terms as they are. Each of these terms consists of 2-3 words. And I want to manipulate the ...
1
vote
1answer
2k views

How do I assign a template to the user edit form?

I am trying to create a twig template for user edit page. I have tried /** * Implements hook_theme_suggestions_alter(). */ function my_module_user_theme_suggestions_alter(array &$suggestions, ...
1
vote
1answer
837 views

How to display the rendered entity of the user's profile with comments?

I installed the modules "Twig tweak" and "Profile" In the comment twig, I want to display the rendered entity of the profile ("personnel" type and "teaser" display). I tried this : {{ drupal_entity('...
1
vote
1answer
897 views

on('load') is not working with jQuery 3?

I used to use the following function to load a video in the background (jquery 2.2.4): function getVideo() { if ( $('video').length ) { $('video').each(function() { if (...
1
vote
1answer
188 views

How to print all values of a multi-value field, except the first?

Suppose that in a Twig template, I want to print the first value of a multi-value field, then something else, and finally all other values of the same field. Is there a way to do that? I know how to ...
1
vote
1answer
92 views

How to create global pattern for terms title (not page title)?

I'm trying to override the titles of taxonomy terms. Not the page title, the heading tag at the top of the taxonomy term page. I found the Taxonomy Title module that created to control the title ...
1
vote
3answers
303 views

Can “No front page content has been created yet. Add new content” be removed totally?

I noticed that if there is content placed in the main content block, "No front page content has been created yet. Add new content" will appear on front page or perhaps any page. Most templates will be ...
1
vote
2answers
2k views

Can't disable css caching and aggregation

I've recently installed some modules including wysiyg, ckeditor, ajax comment, b2 nice comments. I then noticed that my css files became cached and aggregated when inspect my pages. I unistalled all ...
1
vote
1answer
119 views

Which tables are safe to omit from sql-sync?

I sync my database with drush sql-sync @dev @live and the other way round. Can I omit the following tables safely, like in my drushrc.php from sql-sync? $options['structure-tables'] = array( '...
1
vote
4answers
4k views

Custom classes for menu links

How can I add custom classes for links into main menu in Drupal 8. This is template for my main menu called menu--main.html.twig {% import _self as menus %} {{ menus.menu_links(items, attributes, 0) }...
1
vote
4answers
4k views

Drupal 7 : How to break title of content into multiple lines

Most of the content-nodes on my site have two parts (English | Arabic). I want to put a line break between the two, so that the broken text does not look awkward. But when I put an html line-break tag,...
1
vote
2answers
966 views

Unable to login into admin after theme change

I am new to Drupal and to understand the basics I created a new theme in Drupal and enabled it as default. It works fine, however, I am not being able to log in into admin. I reinstalled Drupal and ...
1
vote
4answers
3k views

Drupal render form not rendering a form

I have a cutom module which creates a page with a custom form. the problem is that i don't print whole form at once like : $form = drupal_get_form('custom_example_form', $adverts); print render($form)...
1
vote
2answers
462 views

Conditional Stylesheets Set-up: Using the Module

Problem I'm trying to set-up conditional stylesheets. I've followed the instructions but it's still not registering. What have I done wrong? Set-Up I installed and enabled the conditional ...
1
vote
3answers
1k views

Wrapping javascript code conditionally using a cookie

I want to include the following code in page.tpl.php only once during first site visit and for subsequently not. I mean this will pop-up an ad only once. I want to set it based on a cookie. How to ...
1
vote
2answers
257 views

Format 'Table Of Files' Field Display For Commerce Product Display?

We have a Commerce Product Display for a Product Variation. If you're not familiar with Commerce Kickstart, it's basically just a form to add an item to a shopping cart. Each Product Display includes ...
1
vote
2answers
1k views

Views/Block: Only display if node field has a value

I've created a Block in Views. I only want this Block to display if a boolean field on the node is ticked. The View itself should only display content that relates to the node. How can I do this? ...
1
vote
1answer
3k views

How to print formatted contents of Computed Field and Full HTML Textarea in a custom template?

I have used this code to print normal text fields in a print.tpl.php template file: <?php if(isset($node->field_mytextfield['und'][0]['value'])) { print $node->field_mytextfield['...
1
vote
2answers
2k views

node_presave doesn't work

I'm trying to do something before my invoice saves. In my invoice module I have: function invoice_node_presave($node) { var_dump($node); die; if ($node->type == 'invoice') { // If true we ...
1
vote
4answers
924 views

Considerations displaying page titles in page or node template

This is very similar to this, hopefully its different enough to warrant its own question: How to display a field before node title?. On our Drupal sites we have a dozen content types, many of which ...
1
vote
0answers
2k views

Templating a View with “multiple fields”

I'm templating (modifying the .tpl.php files) of a View which has a field with multiple outcomes. This can be controlled using the "Multiple field settings" options. (see screenshot) How I can ...
1
vote
1answer
3k views

custom generate pdf with the header displaying only in the first page

I'm using print module to generate pdf files from the drupal content. Here I use tcpdf library. The pdf files are working fine. But I want to customize the pdf files, here I want to display header in ...
1
vote
2answers
215 views

How can I show a single block only if the user is on iOS?

I have a Picture content type that allows users to upload picture files, something that iOS does not support. Since Apple in 2012 can't support something my first computer running Netscape Navigator ...

1
14 15
16
17 18
20