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

How do I divide a row in sub rows?

If I want to divide a row into some sub-rows in Drupal 8, what should the code be? The following code worked fine for simple tables. I need to do something with the $rows array to divide the rows in ...
1
vote
1answer
389 views

Can't add block in a region

I'm using a Drupal 7 version website and I'm trying to add a block to a region, when I go in blocks and try to add the block to the region and I do save it reply me that it has been saved but no block ...
0
votes
1answer
378 views

How can I alter (theme) the default content feed?

How can I alter (theme) the default content feed on the front page (the list of node teasers) so that my 'thumbnail' image style is used instead of my 'medium' style for the images contained in the ...
-2
votes
0answers
14 views

How to create a token of the rendered entity of the author? [on hold]

I have a site with Drupal 8 and the Message and Token modules. I created custom tokens for my custom module based on the Message module. Here is the file I added to my module : ...
0
votes
0answers
23 views

Is it possible to execute a function on a user object in Twig?

You can use hook_entity_load to add fields to the user object like so: function mymodule_entity_load($entities, $type) { if ($type == 'user' ) { foreach($entities as $e) { $e-...
0
votes
0answers
12 views

How to specifically define name and value attributes for checkboxes form element?

I am trying to build a form parallel to an existing 3rd party html newsletter form (from CleverReach). The final checkbox markup needs to look like this: <input name="1130400[]" value="lorem ipsum"...
0
votes
1answer
49 views

Add body class depending on current URL

I have an URL textarea and I want to add a body class if the current URL is one of those that the user has input in the textarea. This is my current code: function ...
3
votes
2answers
1k views

How do I add a css class to body from a page callback function?

I have a module that produces a lot of pages. A set of these are handled by a particular part of my application, and I would like all these to have a class added to either html or body. I'd settle for ...
2
votes
3answers
43 views

Get node ID or URL in Twig on field level

I have a field value, which I would like to link to the content (to the node itself, using it in a teaser). How can I get the URL or at least the ID on field level, to create that link?
0
votes
1answer
463 views

How to print a taxonomy term's field value alongside a Views grouping header?

In Drupal 8.4.4 I have a "Living Things" taxonomy vocabulary. One field on the terms in the vocabulary is "Most Common Name", with machine name field_most_common_name. On my "Animalia" term its value ...
0
votes
0answers
344 views

Replace menu item with fontawesome icon without an extra module

I know there are several possibilities to use icons in menus with modules. Is there also a way to replace a menu item link with a fontawesome icon without installing a module? I only need to replace ...
1
vote
1answer
18 views

Display summary + read more links if body content is long, otherwise display body alone

We have a content type which has a customized template. In general, the body content of these nodes is short -- one to two sentences at most. In some cases, however, the body content is a paragraph ...
1
vote
1answer
609 views

How do you override the add or edit node for a particular content type

I want to format the editing or adding form for the article content type. i.e. node/add/article path and editing the same article. I copied over the node-edit-form.html.twig template from core/modules/...
-2
votes
0answers
17 views

Changing Bootstrap 3 mobile menu breakpoints

I would like to change the width the mobile menu in the bootstrap theme appears instead of the desktop menu. I have my own subtheme created from the bootstrap base theme. Currently the mobile menu ...
0
votes
1answer
454 views

Admin toolbar not displaying correctly in custom theme using bootstrap

I've created custom Drupal 8 theme using bootstrap. Everything is fine except admin toolbar. Toolbar is displaying correctly in backend but in frontend is only displays the "Manage,shortcuts, admin" ...
0
votes
1answer
13 views

Display long text fields as type text input not as textarea on node forms

I have some fields which are configured as long text fields, which I need to display as <input type="text /> instead of <textarea></textarea>. I'm trying to find the correct naming ...
0
votes
2answers
638 views

Twig D8 Field Format

Is it possible via Twig to output a field's value, that uses the fields formatter. I would like to display a file field two different ways in the same twig file. The first will be a link to the file ...
-2
votes
0answers
24 views

Get $tempstore inside Twig

I'm creating a module my_module, I want to tempstore a variable and get it inside a Twig template. Here's my controller: $tempstore = \Drupal::service('user.private_tempstore')->get('mymodule'); $...
42
votes
15answers
63k views

Getting the image URL from a field_image on a node

So I have this Node: object(Drupal\node\Entity\Node)[1862] protected 'values' => array (size=17) 'vid' => array (size=1) 'x-default' => string '7' (length=1) ...
0
votes
3answers
487 views

How to get image url in a twig file from a media entity

Normally I am able to get an images url by setting the display setting for that field to url and then writing something similar to this in order to print the url {{ content.field_image.0['#markup'] ...
-2
votes
0answers
40 views

How to display the rendered entity of a reference field in a template? [on hold]

I have the Message module installed on my site. I created a message template for the new node created in my sub theme. Nodes have a display mode called message_activity_stream How to display this ...
1
vote
1answer
471 views

Drupal 7 theme table row array will not show

I have the below code and I know both the $headers and the $html have values stored in them as i can echo them out. I can also set the 'header' => in the theme function to be either $header or $html ...
0
votes
1answer
639 views

add mime type for js file

I want to add mime type for js file 'youtube.js' which helps to pause and play the youtube video.I have included in info file as scripts[] = js/YoutubeVideo.js. I caught the error The resource ...
0
votes
1answer
409 views

right sidebar doesn't shrink in zen responsive theme

I have a Zen 7.x.5.x Responsive subtheme with Right sidebar... I know, I am new with all this responsiveness staff; but - I think the right sidebar doesn't shrink when I resize my browser....it just ...
0
votes
1answer
406 views

Use form_alter to change description under reset password field for user_pass form

I'd like to change the text below the reset password field. I took a look at this answer, and it talks about changing the button, but I need a bit of help to change the text. Here is the debug ...
0
votes
3answers
516 views

Styling label of a select list thorugh form API

I want to style the label of my select list with bold font and give it some color. This is the code for rendering form which I am using in a hook_block_view $form['dropdown_first'] = array( '#...
-2
votes
0answers
30 views

any idea on how to make background width of some fields of content region to full width of webbrouser screen? [closed]

I'm trying to implement new design to web site (Drupal 8, adaptive theme). idea of web page design is to have in some areas background image with width of 100% 0f browser window. There was no problem ...
0
votes
1answer
515 views

How to theme the taxonomy add/edit term form?

I would like to change the design of the taxonomy add/edit term form, how do you create a template for the taxonomy "Add Term" / "Edit Term" just like creating a node form template? Not creating a ...
-1
votes
0answers
31 views

How to display message author info [on hold]

I have the module Message installed on a Drupal 8 site. I want to display the information of the author of a message but I can't figure out how to do it. How can I display: the url of the account of ...
3
votes
1answer
406 views

Templating JSON

Is there a Drupal way to template the results of ajax query that returns JSON. The JSON is is being returned to some php module code. If there is not a Drupal way I was thinking of using something ...
1
vote
2answers
462 views

Changing Site Background on button (and carrying it over to all pages on site)

i'm trying to create a drupal site where under the logo, there would be three options visisble (light, dark, color), and once the user clicks on one of them, the site background will change. now i ...
1
vote
1answer
437 views

How do I install a 3rd party PHP library in sites/all/libraries - can I just plonk it in there?

For example, according to the Drupal module s3fs, I can -- to quote their README.txt :- 2b) If you don't have drush, go to to http://aws.amazon.com/sdk-for-php and click the orange "AWS SDK for ...
0
votes
1answer
440 views

How would I call the forms to be displayed under their respective section? [closed]

In Drupal 8 I have four contact form, The name of form are one, two, three and four, all having the same fields name, phone, email and a file attachment field. Now I want to display each form on one ...
1
vote
0answers
35 views

How to display the parent node or product of a comment?

I installed the Message module on my site. I created a custom module that created a message when a comment is created. https://imgur.com/a/4OLhGlL How to display the parent node or product of a ...
-5
votes
0answers
17 views

jQuery upgrade conflict JS due to collapse text module [closed]

After upgrade jQuery version to 3.1, jQuery get conflicted due to deprecated function andself. As collapse text module call core js file misc/form.js which have andself function. This function is ...
1
vote
2answers
353 views

How to use the flag counter in a twig template of a node?

The version dev of the module "Flag" for "Drupal 8" has added a new sub module "Flag Count": https://www.drupal.org/project/flag/issues/2708291 I copied the code {% set count = '[' ~ flagcount(flag,...
0
votes
1answer
410 views

JS Resize function for div containing a a slideview slideshow and set as a page background

This is for a drpal 7 install. Is there a way to apply the same function they discuss in this thread https://stackoverflow.com/questions/10373349/height-and-width-of-background-picture-adapt-to-each-...
0
votes
1answer
12 views

Is there a field tpl for body and/or title fields?

I need to add some data- attributes and I am hoping to change it for the body and title fields on article content types. Do the title/body have tpl's that I can modify to add these? Or another method ...
0
votes
1answer
32 views

Overriding radio button rendering

I have a List (text) field on a comment type. This field is required and only one option may be chosen, so a radio button is how it will be rendered. I would now like to change the way the radio ...
0
votes
1answer
402 views

How can I extract and print specific field values from $page['content'] in page.tpl.php (vocabulary page)

I am trying to print some specific fields on a vocabulary term page in order to lay the page the way I want. <?php print render($page['content']); ?> prints the entire content but I want to ...
0
votes
1answer
459 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
2answers
349 views

hook_user_login not working

After user enter email and password. hook_user_login gets triggered and excute below code. I am placing code in "bootstap_business.theme" file like this function hook_user_login($account) { $email = ...
1
vote
1answer
422 views

How to get all node ids from same content type

I am using Drupal 8 and I want to create related content, but the problem is that I can't figure it out, how I can get all node IDs(except current one) for a specific content type.
2
votes
1answer
559 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
3answers
259 views

Print multiple files field links, descriptions and file extensions in Twig

I have a content type with a field field_file_attachment that allows uploading multiple files with txt, pdf, gif and img extensions. I would like to get links, descriptions and extensions of all ...
4
votes
1answer
95 views

Custom theme: variable not made available in menu template

I've created a custom theme, let's call it "mytheme" in the examples, with the "classy" theme as base. I use several templates, one is menu--account.html.twig, it's an override I made of the classy ...
1
vote
1answer
389 views

Customize admin contenttype page design in drupal 7?

i have created template file for my contenttype wallpaper but i don't know how to get form design in that page. for example my content type name is wallpaper, so i create template file for page--...
10
votes
4answers
7k views

Loop through child elements in Twig like Element::children()

When dealing with a renderable array in PHP, I can use Element::children() to access the elements that are not # properties but subordinated renderable elements (form items inside a fieldset, items ...
1
vote
1answer
39 views

Add CSS class to view image_field in twig

In my custom view fields twig file views-view-fields--search--product_result.html.twig I try to theme my view item. {{ fields.field_images.content }} <h5 class="card-title">{{ fields.title....
1
vote
1answer
43 views

Change field label used in node display

I have a custom content type in Drupal 8.6.x. I want to be able to change the text used for a field label based on the value of a taxonomy term reference in the node. For example, I want to change ...