The preprocess functions are functions that are executed directly before a theme function is invoked.

learn more… | top users | synonyms

0
votes
0answers
4 views

Where to render? Preprocess or template?

We are constantly improving our coding performance and we are monitoring every page load to optimize loading en rendering times in our websites. Above statement in mind, I stumbled upon the question ...
1
vote
1answer
36 views

Passing a custom variable from preprocess view to a template file

I am preprocessing a view in order to create a custom variable and then pass it to a view template file. I have added the following code to the template.php file: function ...
1
vote
0answers
20 views

Variable in theme_preprocess_page is changed before page.tpl.php

In my theme_preprocess_page() function, I set a variable to a default value. Then, in an if(!empty($variables['node'])) { } block, I do various calculations to give that variable the value I actually ...
2
votes
0answers
19 views

Pass variable to field template from theme_preprocess_field()

I'm stuck trying to pass variables from my theme_preprocess_field function to my template file. I want to have a variable for each of the fields I am printing out to my template. I'm using the ...
0
votes
1answer
14 views

Creating a new variable by combining 2 field values [duplicate]

In my theme’s preprocess node function i’m trying to create a new variable by combining 2 existing fields, both of which are text strings. pseudo code is this: $teachers_name = $firstname + ...
1
vote
1answer
20 views

What's the best way to create variables that are available to every single URL on my site, based on node id or taxonomy id?

On Drupal site A we have a bunch of links to non-Drupal site B. For marketing and tracking purposes all these links have a different URL variable appended to them, so that when a user registers on ...
0
votes
1answer
24 views

Order of preprocess functions in drupal

I have started learning drupal for few months. Now I'm doing some theming. I would like to know the execution order of pre-process functions.
0
votes
1answer
69 views

unsetting css is not working

I am trying to unsetting the deafult CSS through a foreach loop, but seems its not working in hook_preprocess_html(&$variables) here is my code, please have a look. $arrCSS = drupal_add_css(); ...
0
votes
1answer
30 views

hook_preprocess_html in my module

I am having a content type with fields select list, js, css, and body. In the select box it list a number of templates to apply on the current node. I have these custom templates in the templates ...
0
votes
1answer
13 views

How to edit Drupal core rdf.module functionality

Using drupal's core RDF module there is a function (shown below) that add "xml:lang" attibute to tags. What I want to do is to change this functionality so that ...
0
votes
1answer
21 views

Theme_hook_suggestions not working

I'm using hook_preprocess_node in a module. In that, I check whether the node type, and on satisfying the condition I'm doing a theme_hook_suggestions. My tpl.php files are inside my modules template ...
0
votes
1answer
13 views

Problems with EVA generated html

I want to show a list of links to the 5 latest news on my homepage. I learned that I can install the Views module to make a snapshot of a content type. I also use EVA to create a EVA field from the ...
0
votes
1answer
17 views

Get nid inside preprocess function

My goal is to have an additional region class, when region is rendered on my page--node--9 I am using this template_preprocess_region() function to do this. But how i can get inside my function ID ...
0
votes
1answer
94 views

Drupal 8: Read field value from $variables in preprocess_html

I've been wrestling with Drupal 8 for some time now and have run into a little problem. I want to get a field value from a content type that I can use in my html--front.html.twig. I can create a new ...
0
votes
0answers
7 views

How to add themeable content to a term display with Display Suite

So I thought I understood this, but apparently not. I have a module that implements hook_preprocess_taxonomy_term() to add on a 'starrable' element. function ...
1
vote
1answer
23 views

Changing value of a field before rendering in Drupal 7

I am trying to change the value of a field. I need to add a dynamic class on-the-fly, based on some complext context, and I need to warp the text value with the span-class-stuff. But I haven't been ...
0
votes
0answers
24 views

How to use preprocess on a File Entity field?

I'm trying to implement the following code on a multi-value image field. I'm using File Entity to add another field to the image (field_alignment) function ...
0
votes
1answer
29 views

Check for IE8 in theme_preprocess_page function

I'm trying to use inline svgs for a number of logos and icons, and I was considering adding the inline svg code in a preprocess function. This seems like a good place to check for svg support (namely, ...
0
votes
1answer
40 views

View of taxonomy terms - add preprocess class

I have a view showing taxonomy terms with an images field. I'd like to add a class .has-images if the images field is not empty. I've done this before with nodes using preprocess, have tried ...
1
vote
3answers
70 views

Hide page title on specific path

I want to hide page title on a specific path, but I want to retain the page title between "title" tags in the header. I want the title to be exist in title bar of the browser, but that should not be ...
0
votes
0answers
45 views

How to use preprocess field to style radio buttons

Trying to set up a preprocess_field.I have list field by radio buttons and I want to override the output like this: <div class="field field-name-field-event-status field-type-list-text ...
0
votes
0answers
10 views

Preprocess function values not persisting

I am having a really bizarre problem over the last few days. I'm trying to alter a field value through a preprocess function and while I can see the value has been changed inside the function, it ...
0
votes
2answers
68 views

How to remove JS from a page during preprocess D7

I'm trying to remove few JS files from one page, which will be called in an Iframe (so no TEMPLATE_js_alter possible because of the if condition). This code below unset the JS but they are still ...
0
votes
1answer
34 views

How do I hide the page title based on node type using template_preprocess_page()?

In Drupal 7, this was possible. (See How to hide page title based on node type using template_preprocess_page().) function MYTHEME_preprocess_page(&$variables) { if (!empty($variables['node']) ...
0
votes
2answers
41 views

Define variables for specific template

I would like to pass variables to a single specific template file(tpl.php). My setting is the following: my_entities.module function my_entities_theme($existing, $type, $theme, $path) { return ...
1
vote
1answer
92 views

How to preprocess output of $user_picture in Drupal 7?

By default user picture output markup looks like this: <div class="user-picture"> <a href="/user/username" class="active"> <img class="img-responsive" ...
0
votes
1answer
27 views

How to theme a preprocess function output with a default, without the need of a .tpl file?

I created this simple function in order to print out the commerce order author UID and email. How may I add the output of the function inside the messages area, without creating a special .tpl? I ...
0
votes
1answer
53 views

Add tid or name as a class to each item of a taxonomy term

I'd like to add the term ID or the name of the term as a class to each one of my taxonomy terms on a node page. note that I'm not using views, so I wonder how can I achieve this via template.php or ...
0
votes
0answers
28 views

node.tpl.php is not getting picked

I have a content type called news, I wanted to create a custom template for it because I had to embed a view just before the title. I created node--news.tpl.php and placed it in templates folder but ...
0
votes
1answer
20 views

Add node ID to template variables

is there any way to add node ID (if it exists) to template variables using my_theme_preprocess_page(&vars) function? It looks like theme theme isn't using my_theme_preprocess_node(&$vars, ...
1
vote
1answer
48 views

Print node tags in html header

I am trying to print the articles tags in the meta area of the html. I am able to print them, however, they contain all the markup, where as I just need the plain text, comma separated list, much like ...
0
votes
2answers
30 views

Adding JS to a form within Omega 4 theme

I need to add some JavaScript to forms within my Omega 4 theme. My code right now is: function mytheme_preprocess_form(&$vars) { $vars['element']['#attached']['js'][] = 'path/to/myjs'; } ...
1
vote
2answers
83 views

How to fix active-class problem in minicalendar with calendar / exposed filters

I have a calendar view for events. The events are categorized by taxonomy terms. I use the minicalendar for the selection of days and filter the result list with an exposed list of the categories. ...
0
votes
2answers
85 views

Combining fields in preprocess template

I want to combine two fields (say first name and last name) of a particular type of node so that the name displays correctly and I still have the individual fields to work with in different areas. I ...
0
votes
0answers
48 views

how to override output in preprocess function

I am trying to override the path of events created by the fullcalendar module. I am having some issues, and came up with a very general Drupal question: In a preprocess function, I can modify the ...
0
votes
2answers
53 views

How to set body content using preprocess_node?

I need to alter the body html for a specific content type which will be processed by the Pagination module. I think preprocess_node will work, but I'm having trouble figuring out how to change the ...
1
vote
1answer
109 views

How to show all template suggestions for a page without using Devel Themer?

For some reason the Theme developer module doesn't work on my site (whenever i activate it and navigate on my site it just shows a white page with written "Jump to main content"), but all I want to ...
0
votes
1answer
42 views

Change layout of views page based on taxonomy term field

I have a taxonomy term page being displayed via a Views 'page' display. I need to change a value in the header of the site (above the level of the view) based on the value of one of the fields in the ...
0
votes
1answer
50 views

Add markup before form output for user-login

I've created a template override for the user login form (user-login.tpl.php) and want to put some content before the form's elements (e.g, header text and copy). Anything you add in ...
0
votes
0answers
29 views

preprocess_field only applies to one view

I have four separate views that randomly load an image on the page. Each view is set up identically and rely on Views Auto refresh to randomly load an image. My problem is that my preprocess works ...
2
votes
4answers
208 views

How to merge results from two different views?

I need to write an impossible view and I achieve to retrieve the correct list of nodes in two different views and now I need to merge the results in one single table. How can I merge it? If the ...
1
vote
1answer
69 views

is it possible to add a class to header found in page.tpl based on a node id?

first off, i’m using Adaptive Theme so maybe this won’t make sense using a different theme. but here i want to add a class to <header id=“main-content-header” class="someclasses"> which is ...
5
votes
1answer
498 views

Trying to add an html head tag in Drupal 8, beta 2

With Drupal 8.0 beta2, drupal_add_html_head() has been deprecated in favor of #attached. So the old way was: function MYTHEME_page_build(&$page) { $viewport = array( '#type' => ...
-1
votes
1answer
54 views

What is wrong with this drupal 7 preprocess function to output a fields value into the body classes?

I have the following preprocess function and was wondering what I have wrong here as its not working. This is just to grab a fields value and insert it into the body classes. /** * Implements ...
0
votes
1answer
96 views

Creating Preprocess function to add extra classes dependent on field value

I have a content type called "article" and I have a field called "text color" and I want to add this text color field's value as a class to either the body or content container and change the text ...
0
votes
1answer
89 views

How to apply a function to the title of a teaser made with display suite?

I'm pretty new to functions and PHP (so please forgive my terminology) but here's what I would like to do: Background My homepage contains a view displaying various content type teasers. I would ...
0
votes
0answers
180 views

Add class to views row in preprocess function? [duplicate]

I wanna make a view with an integer field. If the value of the integer field in a row is more then x% of the average I wanna add a class to it. In what preprocess function would I do the calculation ...
0
votes
1answer
38 views

Which hook to use in a custom module for tracking access to one particular page?

I'm probably not fully awake this morning because it seems so trivial but I cannot figure it out. I need a hook to track when user access a certain page (path = 'export-csv'). This page is not a node ...
0
votes
0answers
31 views

is possible to load a custom panel.tpl.php based on a node id in the panel

is it possible to load a pane.tpl based on a node id contained in the page? something like this would be done within preprocess_page..? theme developer says the pane id is 2 so the pseudo code would ...
0
votes
2answers
51 views

How do I add different URL to the HOME link in the breadcrumb for the authenticated user

I'm using breadcrumbs in my drupal 7 website. How and where do I change the URL for the [home] breadcrumb, based on role/authentication of the user - when the authenticated user signs in, they are ...