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

learn more… | top users | synonyms

1
vote
0answers
21 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
36 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
53 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
15 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
24 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
24 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
79 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']); ...
0
votes
1answer
28 views

Custom Block - How to get additional variables

I am new to Drupal and slowly getting my head around it. I'm using Pay to Publish module on my site, I've setup a custom block that gets recent posted advert (very simple) now I want to style the ...
0
votes
2answers
23 views

How to conditionally render fields with a different formatter

I have a content type with two fields one called display which is a simple list and the other is an entityreference field. I would like to change how the entity reference field is rendered depending ...
0
votes
0answers
23 views

Panelized content in Preprocess Page

I have been badly stuck with some preprocess issues of a panelized node...I need to change output of certain fields in panes,but in preprocess_page, the %markup is rendered array in the form of ...
0
votes
1answer
28 views

Preprocess Panels or Panelizer content

I am trying to change output of some of the fields used inside my panelizer content, i.e node pages, but hook_preprocess_page( &$vars) is showing the output as rendered #markup and i just cant get ...
0
votes
0answers
13 views

Understanding field slideshows available variables

I am actually trying to write a patch for the field slideshow module. At the moment i am a little bit stuck with some kind of understandment how the following works: In the field_slideshow.tpl.php is ...
0
votes
1answer
40 views

preg_replace() not working on node title in hook_preprocess_page()

Here's code from my module: function mymodule_preprocess_page(&$variables) { // load the node object $node = node_load(arg(1)); $fied = $node->field_building_sell['und'][0]['value']; ...
0
votes
0answers
28 views

index in multi value fields in Drupal

I've created a content type called Event which has a date field (field_date) that accepts multiple values using Date Repeat API of the Calendar module. I also created two different blocks using Views ...
0
votes
0answers
26 views

Variables not passed to view template

Initially I implemented logic to show results summary inside the views template file realia-view-grid--apartments--listing-row-filtered.tpl Since best practices is to implement it in the ...
1
vote
1answer
77 views

Drupal add class to body if page is unpublished [duplicate]

I would like to be able to add an unpublished class to the body tag of a node (for both its main view and edit view) if the node has been unpublished. How can I do this? Steps I have taken: 1) ...
0
votes
1answer
32 views

sort comments descending programmatically

I want to sort all comment descending programmatically, I found this Comments sorted by oldest first but I dont want use those modules or views solution. anybody know how can I sort comment ...
0
votes
1answer
19 views

Fetch a view into hook_preprcess_node and then put it in a block

I want to fetch a view in my template_preprocess_node function and then put in in a block, so I can diplay it in the sidebars of my page. I have the view (the code below) but don't know how to put it ...
0
votes
2answers
39 views

Targeting non admin pages (front end) from a module

From my custom module I'd like to target essentially all front end pages on my site whether it be a node, front page, a views page or taxonomy page. I started out thinking it would be better to use ...
1
vote
0answers
28 views

Whats the proper way to preprocess field collection items to add first and last class names?

How to add 'first' and 'last' class names in addtion to 'odd'/ 'even' for field collection items in preprocess functions?
0
votes
1answer
26 views

How to desactivate jquery_update logic for the homepage

The objective of this is to remove all legacy javascript files from the homepage except for the new javascript files I specifically want to load. Here is how I remove all the Javascript files I don't ...
0
votes
0answers
31 views

Drupal views grids alternate number of columns per row template preprocessor

im using views with the grid display option, but my interface requirement needs to alternate between 3 columns then 2 columns. can anyone recommend and template hooks for the preprocessor to achieve ...
1
vote
1answer
39 views

How to remove the create prefix text when adding new content?

Tried a couple of attempts and no luck with function framework_preprocess function framework_preprocess_ask_a_question(&$vars, $hook) { if (arg(0) == 'node' && arg(1) == 'add' ...
0
votes
0answers
28 views

differences between suggesting theme_hook in node and page preprocess function

I used to suggest the theme hooks in MyTheme_preprocess_page() function in template.php. I mean some thing like this: $suggest = "page__node__ContentType"; $variables['theme_hook_suggestions'][] = ...
0
votes
1answer
50 views

Function preprocess_views_view if not logged in

I have added two javascripts for one page only using preprosess in template.php. The two scripts seem to work well. The jquery version I include on this page/view is interfering with admin overlay ...
0
votes
1answer
50 views

how to get the values of a view in _preprocess_views_view_fields drupal7

I have a view of multiple content types. I only select the name and an image from those content types so I'm sure what the format of output is going to be. how can I get the field values of view in ...
1
vote
2answers
115 views

How do I preprocess_html() a panelized page?

My intentions is to take a panelized page and use fields provided in that page to create class names on the body element. When I preprocess the page, I don't get the original node information and ...
0
votes
2answers
48 views

how to set a node title on node creation?

I need to specify node titles when the node is created. I am hiding the title field from users and have everything working to generate the correct title but I can't seem to get that title into the ...
0
votes
3answers
71 views

How can I redirect user/*/edit to another page based on user content?

I have a site with the following relationship: for every user, there is one corresponding (node) profile. For the user/*/edit, I would like the user to actually edit their profile node, not the user ...
4
votes
1answer
137 views

Working with template suggestions on Drupal 8

I need Drupal to use a custom page template if the URL contains a particular _GET parameter. In D7 I would do something like this in the theme's template.php: function ...
0
votes
1answer
37 views

suggestions needed to define a class for field per entity/node

Im not sure the best way to go about this, and not so much a big programmer... I would like to let the node creator decide whether the image in the image field should be top, left, or right. So i ...
0
votes
0answers
44 views

Inconsistent “UND” value in node fields

I'm manually printing my node fields on its template (node--TYPE.tpl.php). Something like: <div class="row"> <div class="press-year col-md-12"> <h2><?php print $year; ...
5
votes
3answers
670 views

Adding JS to a Drupal 8 theme (replacement for drupal_add_js)

In Drupal 7, I can use drupal_add_js within a theme's template.php file as a theme_preprocess_html(&$vars) function: drupal_add_js(drupal_get_path('theme', 'mytheme') . '/js/scripts.js', ...
2
votes
1answer
100 views

Display Suite ignores hook_preprocess_node()

It seems like Display Suite completely ignore hook_preprocess_node() and hook_process_node() - is this the case? If so, what is the preferred way to make minor changes to the final rendering with ...
3
votes
1answer
94 views

What is the execution sequence of functions while rendering a form?

I have a form in my website with id: sample_test_custom_form. I have used hook_form_alter in a custom module to alter this form. I also have a preprocess function ...
0
votes
0answers
61 views

How do i test wether a view inside a panel is empty?

I have a view inside a panel (node-panel). The layout of my panel is handled in my-panel-layout.tlp.php. Now when my view is empty It's title and fields are no longer displayed. I would still like ...
0
votes
2answers
84 views

How to disable links in taxonomy term node fields

I have a list of rendered taxonomy terms in a node sidebar, rendered as h2 tags, linked to the taxonomy page for that tid. I don't want that term to link anywhere, so I want to remove the link and ...
0
votes
1answer
50 views

How to change field value of a node

I have a field in a node where users entered data in an inconsistent format. I need to parse that data (it's HTML) and re-format it so it looks correct. Where is the best place to do this?
0
votes
1answer
199 views

Trying to remove options form an exposed filter

In drupal 7, I'm trying to remove an exposed taxonomy filter. This taxonomy filter has a depth of 2. I'm only trying to expose the parent item. As a quick fix I'm trying (poorly) to remove them with ...
1
vote
1answer
258 views

how to change the value of the form in the preprocess functions or get the value of the function preprocess

I need to get the value of preprocces function and write it in the form #default_value, while my form is a variable that preprocess functions I create custom module <?php /** * Реализация ...
0
votes
1answer
41 views

Best practices when choosing a method of displaying content?

This is a little broad, but I have a specific example. I'm new to Drupal, with a WordPress background. I'm getting some of the core Drupal concepts down, but I'm left with some questions. How do I ...
3
votes
2answers
98 views

Adding js and css from a module but only to node view, not node edit

I'm adding js and css from a custom module and it works except for the fact that it also adds to the node edit page which I don't want. I have this in my custom module: function ...
0
votes
1answer
197 views

Which are the differences between hook_node_view_alter and hook_preprocess_node?

I have to remove some elements from a node before show it, but I can't understand where it's better to put the code. Mainly I can't understand the differences between hook_node_view_alter and ...
1
vote
0answers
33 views

attach the form to a comment, so that the form relates to specific comment

I need to solve the following. In the Custom Module I created a form that has a text box and click Send. Made for form validation functions and sabmita, then shoved the completed form to the variable ...
1
vote
0answers
130 views

Trying to add class to body, based on taxonomy from a product/node

Be kind to me, my forte is definitely NOT in the pre-process area... or hooks, etc. :-) I'm using Omega 3.x in Drupal 7. I found a nice function that pulls the user's roles and prints each role as a ...
0
votes
2answers
139 views

Altering nodes title value

I am trying to alter the title of my nodes to prevent URLS appearing in any title. This is the code I am using. function mytemplate_preprocess_node(&$variables) { $node = $variables['node ']; ...
0
votes
4answers
312 views

Preprocess function trying to alter title

I have used this code in template.php. function mytemplate_preprocess_node(&$variables) { $variables['title'] = "trial" . check_plain($node->title); } I was trying to alter the page title, ...
0
votes
1answer
449 views

Drupal 7 module hook_preprocess_page &$vars

In my module I have verified this function is being called, but when I try to edit page--golfguide--alias.tpl.php it doesn't have the variables available. In module: function ...
0
votes
0answers
53 views

Removing Node Tabs with _preprocess_page(): Explode string error

Trying to retrieve the array of the Node Tabs (Drupal 7) so I can remove ones if needed (say for a certain role, etc). Currently receiving this error: Warning: explode() expects parameter 2 to be ...
2
votes
2answers
820 views

Rendering a field in a custom print template

I'm using the Printer, email and PDF versions module to render a custom print page in Drupal 7. I'd like to theme the fields individually and have worked that out to the point of using nasty php in my ...