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

learn more… | top users | synonyms

0
votes
2answers
28 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
22 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
32 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
18 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" ...
-2
votes
0answers
31 views

how to remove element from theme

In my project, I use drupal commerce kickstart. There is something made me a little bit confuse when working with theme. In the upload image, you can see red round rectangle, I want to hide or remove ...
0
votes
1answer
19 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
18 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
26 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
15 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
39 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
25 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
76 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
42 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
32 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
23 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
55 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
29 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
36 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
19 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 ...
0
votes
1answer
71 views

How to merge results from two different views?

I need to write an impossible view and I achieve to retrive 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 they're resultes? ...
1
vote
1answer
60 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 ...
4
votes
1answer
328 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
39 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
48 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
59 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
43 views

Add class to views row in preprocess function?

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
30 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
22 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
45 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 ...
1
vote
2answers
80 views

Programmatically changing the global site name?

I'm making a multi-site setup using the same install and the same database, basing it off domains. I'm trying to programmatically alter the site_name variable so that it displays a different site name ...
0
votes
1answer
42 views

Trying to render an array of items with the drupal_add_html_head function

I have a preprocess_html function that gets an array of google fonts and adds them as an html class. I have it partially working but if say I have three fonts, only the last one gets into <html ...
0
votes
1answer
37 views

Form '#theme' preprocess doesn't invoke

I have form where '#theme' => 'ebanq_transfer_theme'. Template file is rendered but preprocess hook doesn't invoke. Any ideas? /** * Implements hook_theme(). */ function ebanq_transfer_theme() { ...
1
vote
2answers
55 views

how can i access a node variable inside of theme_preprocess_page function? [closed]

I'm trying to access a node variable, the id of a taxonomy term but i have to do it at the page level in theme_prepocess_page function. i did it in preprocess node like this $libStatus = ...
0
votes
1answer
20 views

Change function view_unformatted to work with format HTML list

I have function in template.php which check if image fields exists (has content) and it adds classes if image exists (has_field) and if image does not exist (has_no_field). This function now works ...
0
votes
2answers
35 views

Preprocessing function for specific view by name

I'm using drupal 7.29 . I'm trying to write the preprocess function for a specific view named front-page. I have written the following functions in my template.php file: function ...
0
votes
0answers
154 views

How to add class to view block programmatically

I need to add class to view block programmatically, but could not find working way to do it. My view format is Unformatted list. I have this in my template.php: function ...
3
votes
1answer
359 views

Drupal 8 - “Implement menu links as plugins”, trying to build a menu tree

In a previous Drupal 8 menu question here, we determined that menu tree building was now a service. In my D8 contrib theme, I was then able to render the main menu tree as: function ...
0
votes
1answer
119 views

Schema.org itemprop=“url” inside anchor object (link)

I'm trying to use the preprocess function to change the default outpot of links <a href> to include Schema.org's itemprop="url" inside the anchor object, as well as adding a <span ...
0
votes
2answers
84 views

How do I preprocess “extra fields”?

Drupal allows you to create "extra fields" through hook_field_extra-fields. I'd like to be able to load javascript (among other things) in my module, based on the presence of one of these fields, but ...
0
votes
0answers
62 views

Alter webform field before it is rendered

I am VERY new to Drupal (Drupal 7). I am stuck at webform alteration step. So, I have created a content type - News. The News content type has a node reference field for referencing a webform. ...
1
vote
2answers
96 views

Printing current node workflow state name as the page body classes

I have a workflow system in my site using workflow module, and I need to print the node current state name as body class. I did the same with user current role in template.php with this snippet: ...
0
votes
1answer
242 views

How do I add to $page_top in html.tpl.php?

I wanted to add a piece of HTML at the top of all pages, right after <body>. In the #drupal IRC channel I got the recommendation to override html.tpl.php in the theme. That works fine. But isn't ...
0
votes
0answers
102 views

hook_preprocess_views_view_fields not being invoked

This is a problem that is very hard to debug, so any help on how can I bite it - will be appriciated. I have custom theme based on tao that I named "clear" . I put it in sites/default/themes/clear . ...
0
votes
2answers
190 views

Render Block in preprocess page

I try to copy an existing Block and print it in the left sidebar for some content types. That works, but what i`m missing is that i must activate the sidebar first and in the body classes the ...
0
votes
2answers
44 views

How to hide a user profile based on custom field?

I need to allow users to turn off the public display of their profile if they wish too. I created a Boolean field to store whether the user wanted the profile shown or hidden. According to this ...
0
votes
2answers
65 views

presidency of drupal template file

I am new to drupal themeing, I have tried to find the presidency of template files(.tpl.php).. So my question is for a particular scenario if I have html.tpl.php, page.tpl.php, block.tpl.php, ...
0
votes
0answers
40 views

Main Menu not rendering?

Recently we merged our test server with our production server. When this happened, we installed a new theme on production that we had been using on dev. All of a sudden our production site's ...
0
votes
0answers
69 views

Move $title variable to region--content.tpl.php

I'm having a bit of trouble sorting something out. I'm trying to move the $title variable to region--content.tpl.php. I think a preprocess function - some variation of template_preprocess_region is ...
1
vote
3answers
74 views

Wrap a single html tag around each block that's generated from a single view

I'm sure this isn't difficult, but I can't seem to figure it out. I have about 10 block displays generated from one view that needs a single html wrap (Setting the css property in the view itself is ...
0
votes
0answers
85 views

Set Taxonomy term option value to a field value

I want to change to value of the taxonomy term options (in a reference field) from the ID to the value of a field in the vocabulary. Is there a way to do this, preprocessing the term field or ...