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

learn more… | top users | synonyms

0
votes
2answers
23 views

How do I render field outside node

For custom content type page I used this: function MYTHEME_preprocess_page(&$vars, $hook) { if (isset($vars['node'])) { // If the node type is "blog_madness" the template suggestion ...
1
vote
1answer
107 views

How to remove a comment based on it's field value?

I have a multilingual site, Comments in this site include a language field (field_language), so users who send comment to nodes must specify in what language they are sending the comment. On loading a ...
1
vote
1answer
21 views

Set image format of field_view_field image field

I'm using a function to place an image from a user field into nodes that the user creates. The display is set to thumbnail in default, user account and tokens, but it shows up as original in the node. ...
0
votes
1answer
29 views

How to use preprocess function for custom templates defined in hook_theme?

I have a custom module that i've created and I have set the theme template like this: /** * Implemtnation of hook_theme() */ function custom_slider_theme($existing, $type, $theme, $path) { ...
0
votes
2answers
38 views

preprocess_page if front

I have a preprocess_page function that applys classes to my content if there is a sidebar or not. if ($vars['page']['sidebar']) { $vars['content_classes'] = 'cool-class'; } else { ...
0
votes
1answer
30 views

Custom user_register_form for Auto Assign Role registration pages

I'm using a function[a] to get custom templates to work for all pages, including role registration pages set by Auto Assign Role. By setting the role registration path to ...
0
votes
1answer
22 views

Add an attribute to a specific tag in text body of page

I would like to add an attribute to a specific tag in the text body of a page. I was thinking in this direction: add MYTHEME_preprocess_field(&$variables) to template.php apply regular ...
0
votes
1answer
18 views

Duplicate / Triplicate inline javascript

On some pages of my site when inline javascript has been added to page it get added multiple times. I've looked through my base theme (Zen) and my default theme (custom) for anything that may be ...
0
votes
1answer
35 views

How to alter the value used to sort a view?

I have properties that have a rental price. The rental price is a field collection with a value (price) and period (per month, per week). You can sort the properties by price (low to high, or high to ...
0
votes
2answers
38 views

Move “Submitted By” from node.tpl to page.tpl

I'm looking to move "Submitted By" info from node.tpl to page.tpl however when I add the following from node.tpl into page.tpl I get errors. Im assuming I dont have access to those variables, but ...
0
votes
0answers
11 views

Ability to pass data “up” from template_preprocess[whatever] to template_preprocess_page?

I'm using template_preprocess_panels_pane and I have custom css that need to be generated and inserted in the header depending upon data in the panels pane. I can do drupal_add_css from ...
0
votes
2answers
21 views

JS and CSS in hook_preprocess_hook()

In the project I am working on I have created a theme hook that renders a .tpl.php file: /** * Implements hook_theme(). */ function my_module_theme() { $theme['my_module_list'] = array( ...
0
votes
1answer
24 views

Add preprocess to content within body field

I need to be able to wrap an anchor tag with rel="shadowbox" and href with the path to the image on all img tags that are inserted into the body field of a node. I think I can somehow do this with ...
0
votes
1answer
47 views

How can i check if css class exists on page and add new one to the body

something like: function mytheme_preprocess_html(&$vars) { //if css.class exists on page{ $vars['classes_array'][] = 'my-class'; //} } ... All i want is to add class to other elements if ...
0
votes
0answers
12 views

How to add a layout specific hook_preprocess_page to omega 4 using multiple layouts?

I'm using omega 4 and I can't seem to be able to add a preprocess function to any of my pages using layouts This is some tests I've made without any result. Adding: ...
0
votes
3answers
45 views

Hide the page titles of some content types

I found following code on this website http://codekarate.com/content/hiding-page-titles-specific-node-types-drupal-6 to hide the page titles of some content types. Can some one help me rewrite this ...
0
votes
0answers
17 views

how to preprocess a link field to open in a new tab?

I'm trying to preprocess a link field so that it opens in a new tab. After using dpm I can confirm that the blank has been set in the attributes target array. However, the <a> tag does not have ...
0
votes
3answers
56 views

how to get correct user id on page

I've added two custom fields to my user form - field_license and field_download_date. In my preprocess_page function, I'm doing this: if(isset($vars['user'])) { $user_data = ...
0
votes
0answers
15 views

How to preprocess a field collection?

I have a field collection that is an image gallery. It has two fields within it: an image and a caption. I want to preprocess it so that the image title tag is equal to the value of caption. I have ...
1
vote
2answers
32 views

Passing Node Variables to Content and Blocks

I'm really struggling with how to get variables created in page.tpl.php and node.tpl.php in rendered content and blocks. I hope I'm just missing something simple. Basically, I'm trying to have a ...
1
vote
1answer
60 views

Passing variable from preprocess block to the block body

There is a block which its body is produced by PHP Code. I need to set a variable before loading the block and use it in it. This is my code function THEME_preprocess_block(&$variables){ ...
0
votes
0answers
61 views

How to render / preprocess list of entity reference nodes?

I hove a content type that editors can 'attach' related nodes to. When I 'theme' / 'style' nodes of this content type through view mode everything is basically fine: the related nodes are rendered ...
1
vote
2answers
181 views

Preprocess node in module

It's more general question. Just to clarify. I can use preprocess function in my template.php file in a way: function mytheme_preprocess_node(&$vars) { // Do some stuff } But is there a way ...
2
votes
1answer
61 views

How to use AJAX form on custom maintenance page

I have been working to customize our maintenance page via custom template and hook_preprocess_maintenance_page(), the intent is to provide the maintenance message, some static text, as well as a basic ...
1
vote
1answer
40 views

How do you get the display settings of a field on a particular content type/display

I'm looking to preprocess a field. The field type I'm wanting to preprocess is an entity reference field. I need to know what view mode has been selected on the display settings for this field (see ...
7
votes
1answer
169 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
195 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
64 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 ...
4
votes
1answer
181 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
21 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
25 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
61 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
84 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
133 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
25 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
49 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
17 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 ...
1
vote
0answers
20 views

How to change node display according to value of date field

I have a need to display a node differently once a date field ('subscription expiry') of the node has passed. This is for subscription-based content. Ideally I would like to be able to choose a ...
0
votes
1answer
33 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
336 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
10 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
47 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
68 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
38 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
78 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
165 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
77 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
11 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
1answer
53 views

Add Attribute to Textfields in Admin Theme

I'm often working with Pages in RTL Languages where the default Theme and also the admin theme are using RTL languages. What often bothers me, is to use LTR texts like Tokens or Paths in Textfields, ...
0
votes
2answers
170 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 ...