Questions tagged [drupal-preprocess]

Setting up variables for use in a template (preprocess and process functions).

Setting up variables for use in a template (preprocess and process functions).

The main role of the preprocessor is to set up variables to be placed within the template (.tpl.php) files. From Drupal 7 they apply to templates and functions, whereas in Drupal 6 preprocess functions only apply to theming hooks implemented as templates. Plain theme functions do not interact with preprocessors.

11 questions
3
votes
1 answer

How do I query Drupal 8 Media by type?

I've created a Media type called "ad_gallery" can I can't seem to pull in all the entries while preprocessing. I'm trying \Drupal::entityQuery('media')->condition('type','ad_gallery')->execute(); And it's…
Devar-TTY
  • 476
  • 5
  • 22
2
votes
1 answer

How to override template file item-list.html.twig for field_slider_images in Drupal 8?

I want to override the item listing template file core/themes/classy/templates/dataset/item-list.html.twig for listing the fields field_slider_images as well as field_blog_tags respectively of their's multiple values of the field. I have selected…
Parag Kuhikar
  • 485
  • 2
  • 6
  • 17
1
vote
1 answer

Preprocess Node: Function that calls on all node types

In preprocess.node.inc file, each node type calls its corresponding preprocess function. mytheme_preprocess_node__article for article, mytheme_preprocess_node__bio for bio, etc. Is there a function that runs on all these node types? I am trying to…
qtgye
  • 3,580
  • 2
  • 15
  • 30
1
vote
1 answer

How to set variable for all theme templates in Drupal 8?

I want to set few global variables which I need to be available in all my theme's Twig templates in Drupal 8. Drupal 7 documentation mentions preprocess function: themeName_preprocess This one is named after the theme itself. Applies to all…
Robert Kusznier
  • 6,471
  • 9
  • 50
  • 71
0
votes
0 answers

Preprocess function not working with Layout Builder (Drupal 8.9.13)

I use Layout Builder on a Drupal 8 project. I created a few components, some views blocks and some content blocks (made with custom block types from the back office). In the Layout Builder UI, it is possible to add blocks already created or to add a…
gwnll
  • 1
  • 2
0
votes
1 answer

Preprocess suggestions in Drupal 7 without Devel Theme Developer module

Is there any alternative way to get preprocess/process suggestions without using Devel themer (Theme developer) module? Apparently I can use $conf['theme_debug'] = TRUE; to get template suggestions, and dpm or var_dump to list available vars, but I…
Olenka
  • 196
  • 5
0
votes
1 answer

Where to place presave functions?

I need to manipulate a content type (people) before being saved from ADMIN. I need to save the name + surname in the title I know the presave functions (hook_node_presave or hook_entity_presave) should be used. My problem is where should these…
Javier
  • 395
  • 3
  • 18
0
votes
1 answer

How to Create Separate Drupal Templates For Parent and Child Taxonomy Terms?

I have a complex taxonomy hierarchy for product categories. Every main taxonomy term has at least one child term. Some of those child terms have child terms. So in some places the taxonomy tree is one level deep and in other places it is two levels…
0
votes
1 answer

Drupal 7 preprocess single node

Is possible create a preprocess for single node? For example, this is generic for all node: function template_preprocess_node(&$variables) {} we can also call something for single node?like this? i have tried various solution but not work. function…
user2679304
0
votes
2 answers

How to get form submitted values in page_preprocess function in drupal 7

I have some output data from databse on my page (few queries to db in mytheme_page_preprocess function) and i want to do search form (text field and submit button). So, how can i get form submitted values in preprocess function ? Something like…
inJakuzi
  • 151
  • 1
  • 12
-1
votes
2 answers

Drupal7: show 404 page after checks in preprocessing

I have some checks in my preprocessing files for nodes. If one of them is true I would like to show my defined 404 page. How is this possible with a php call?
MaxiNet
  • 1,008
  • 2
  • 14
  • 22