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

learn more… | top users | synonyms

0
votes
1answer
13 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
1answer
17 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
26 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
117 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
25 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 ...
-1
votes
1answer
28 views

Adjust page based on content (add HTML formatting, script tags, etc)

In Drupal 7, I have a system where the content creators of a node can use special characters within the text content of the node to set up special layouts that are translated to additional HTML, ...
0
votes
2answers
41 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
22 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
25 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
27 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
26 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
27 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
1answer
30 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
57 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
19 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
28 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
51 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
27 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
24 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
57 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
32 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
34 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
30 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
36 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
28 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
64 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
31 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
35 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
48 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
31 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
60 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
35 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
89 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
46 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
34 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 ...
0
votes
0answers
26 views

Using original picture after preprocess function

I have a preprocess function (function MYTHEME_preprocess_user_picture()) that scales and crops user pictures throughout the site and they become the default pictures. How can I still have access to ...
0
votes
2answers
65 views

Fatal error: Cannot redeclare MYTHEME_preprocess_user_picture()

If I add the following: function MYTHEME_preprocess_user_picture(&$variables) { $variables['user_picture'] = theme('image_style', array('style_name' => ...
0
votes
1answer
36 views

Need to hide a field for the node author

For a particular content type education i need a field to be hidden for the node author. It works in the template file but not with preprocess. This is my code function ...
0
votes
2answers
79 views

jQuery problem click function [closed]

I'm having trouble doing simple stuff in jQuery. What I wanted was to call a function when something was typed in an input field. Now I'm just trying this: when you click anywhere on the page to ...
-1
votes
2answers
26 views

How can I catch the current node object and make changes into it before it is rendered?

I have a content type with multiple fields. On the node display page I want to do some modification on this node (like. changing label text etc.) and I want to do it for display only. Nothing should ...
0
votes
1answer
39 views

Stylesheet for specific page overwritten by standard css

In my subtheme.info I have : stylesheets[all][] = css/style.css And in my template.php I have: function subtheme_preprocess_page(&$vars) { $path = current_path(); if ($path == ...
1
vote
1answer
54 views

Drupal 8: CDN JS — cannot seem to weight it

I'm adding external JS in my Drupal 8 site (//cdn.leafletjs.com/leaflet-0.7.2/leaflet.js) and I cannot seem to weight it using hook_js_alter. I can weight it if I throw it in a themename.libraries.yml ...
1
vote
0answers
69 views

drupal_static_reset causing errors

I have developed a custom template for a node where I wanted to essentially show the node in a blank white page. I created a file called node--results.tpl.php and page--node--results.tpl.php that ...
0
votes
1answer
42 views

How To Change The $tid to $term_name

I've tried to change this code to show the term name instead of the term ID but now no term name or term id show at all Orginal code for term ID function MYTHEME_preprocess_node(&$vars) { if ...
0
votes
1answer
118 views

Drupal 8 Menu Tree issue in my contrib theme possibly because of “Convert menu tree building to a service.”

Previously, in my Drupal 8 contrib theme, I was rendering the full menu tree as: function gratis_preprocess_page(&$vars, $hook) { // Build the main menu links tree. $vars['primary_nav'] = ...
0
votes
1answer
32 views

Add class that surrounds all tables (or any other node,field etc…) using preprocess template?

I have been able to find information on adding classes to tables and other items in my pages, however, I cannot find any information on wrapping the entire table for example in a div through the ...
-1
votes
1answer
144 views

subtheme preprocess functions inheritance

I'm using Drupal 7 with Boostrap Theme. I put the main theme inside sites/all/themes/ And as a recommanded I put sub-theme in sites/my-site.com/themes/ It's working fine but my question is about ...
3
votes
1answer
66 views

How to override jquery update preprocess page

The objective is to exclude certain javascript files from some sections of the website. I exclude javascript and css files in this way in the template.php file of the theme: function ...
2
votes
3answers
129 views

How to wrap first word of page title in span in drupal 7

I want to implement it with theme_preprocess function. Every my attempt fails. function mdrupal_mono_preprocess_page(&$variables) { $variables['title'] = drupal_get_title($variables['node']); ...