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

learn more… | top users | synonyms

-1
votes
1answer
38 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
50 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
101 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
30 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
19 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
37 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
15 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
16 views

Subtheme preprocess page is not being called

Hi I am using standford openframework and I have a problem in my subtheme I created a template.php and I am trying to call my_preprocess_page function MYTHEME_preprocess_page(&$vars) but it ...
0
votes
0answers
19 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
8 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
31 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
45 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
19 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
29 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
32 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
19 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
33 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
67 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
178 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
61 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
53 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
44 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
55 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
89 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
66 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
63 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
41 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
63 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
27 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
41 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
57 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
51 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 ...
0
votes
0answers
40 views

Page specific js despite loading pages with ajax

I am currently building a small site which loads menus and content using ajax (which works), however I can't find a way to add additional scripts to specific pages. Usually I would add the js.script ...
0
votes
3answers
83 views

How to update field values of a content type's nodes when when viewing a particular content type page

I'd essentially like to alter the values of a specific custom field of a few of nodes before they're displayed in a view on the 'page' of a specific content type. The content type is that will be ...
0
votes
0answers
106 views

Add classes to Field collection Items

I want to add classes to the Field collection items (multiple value field), for a stored value earlier generated by HOOK_preprocess_node. What is path / array to get to the classes_array for the ...
0
votes
1answer
52 views

Using theme_preprocess_node i'm trying to add a class to all images on the page

My code below is not working and i'm not sure why. I've tried a few variants. according to the KPR variables output, the image I'm trying to access is here. $variables['field_about_image'][0] i ...
0
votes
0answers
41 views

Google Authorship markup in Drupal 6

I am trying to implement Google Authorship code which is basically a tag like: <link rel="author" href="https://plus.google.com/26716726176271627617/" /> on the main blog page of a Drupal 6 ...
0
votes
1answer
30 views

Question about template_preprocess functions

i noticed there exists a template_preprocess_field function on the Drupal website, but i added in my template.php files just this... function mytheme_preprocess_field(&$variables, $hook) { ...
1
vote
1answer
54 views

display view mode on node based on field setting or taxonomy term of user profile

I'm using Display Suite which is awesome and an easier solution if you're not a coder. Now that I have created several view modes I'd like to set a particular view mode that is based on a field ...
0
votes
1answer
51 views

Add css file when editing specific content type

I would like to add a css file when editing content of the content type invoice. The link is something like this: node/121/edit . I've tried it with it with preprocess_node like this: function ...
0
votes
3answers
89 views

How to print preprocess_html variables in page.tpl

I have variable in template.php to use in different files like page.tpl, but written this in preprocess_html function as below, how can i print this in page.tpl and html.tpl file. ...
0
votes
1answer
35 views

Custom status message on a Views page

I have different urls : domain.com/blog : a list of articles made with Views module domain.com/blog/article-title : article alias domain.com/newsletter/confirm/add/xyz/ok : confirmation link sent to ...
0
votes
0answers
80 views

How to add css using the Preprocess_image function

I'm trying to preprocess my image style like this example <img class="media-object img-rounded img-responsive" src="http://placehold.it/350x250"> My preprocess_image function is not adding ...
0
votes
1answer
91 views

Why is my theme's block preprocess function not reordering elements?

I'm trying to do something that seems fairly basic, but I'm having loads of trouble. The drupal search_form block outputs an input field and a submit button, in that order. I'd like to swap the ...
0
votes
4answers
33 views

what variable can i use to identify a specific pages

i need to load a diff stylesheet depending upon which page the user is on. when using: themename_preprocess_page(){kpr(&$variables;)} i thought i'd see a pageId or pageTitle in which i ...
0
votes
2answers
81 views

How to change page CSS based on parent menu item?

I'm building a fairly simple site, and I need to alter a background image based on what section the user is in. The main menu only has 2 levels. I'm unsure where I should hook into in order to be able ...
0
votes
1answer
50 views

Can you preprocess a specific region in template.php?

In your template.php file, I know you can use theme_preprocess_region and check what "region" you are in, and accomplish what I am attempting like that...but I was wondering if you can do something ...
0
votes
1answer
108 views

dd a class=“” to anchor on the “read more” links of a node

How I can add a class="" to anchor on the "read more" links of a node. Im use a bootstrap theme and i need add de btn-default class to anchors, thanks <ul class="links list-inline"> <li ...
0
votes
0answers
60 views

Undefined variable from variable in template.php

In template.php I have this function. function my_theme_process_page(&$variables) { $menu_tree = menu_tree_all_data('main-menu'); $variables['main_menu'] = menu_tree_output($menu_tree); ...
0
votes
2answers
38 views

Applying image style to authors pictures in comments without preprocess function

Is there anyway I could apply an image style to the user picture in comments without using a preprocess function (YOURTHEME_preprocess_user_picture?) The reason I ask this is because the preprocess ...