I have some fields that I can't retrieve in Views, so I can't add them to the templates. I can do a db query later to get those fields with the nid. How do I add those extra fields to the templates? Is the best way to just copy&paste the preprocess functions from the module, stick them into template.php, and then modify them to include the newly added fields? Thx.

Comments

ppblaauw’s picture

Status: Active » Postponed (maintainer needs more info)

yes, you can always create a preprocess function in the theme to add additional variables to the $vars array.
Like in the previous why in version 1 of the module.

Hope this helps you further, please let me know.

sinmao’s picture

Hi Philip,

So if I want to add more fields to $views_slideshow_ddblock_slider_items in the ddblock templates, would this be the function I would add to template.php:

function template_preprocess_views_slideshow_ddblock(&$vars) {
$vars[views_slideshow_ddblock_slider_items][] = array('key', 'value');
}
(this doesn't seem right since it would overwrite that function in views_slideshow_ddblock.module, right?)

Or would I have to copy the entire template_preprocess_views_slideshow_ddblock() function in views_slideshow_ddblock.module to template.php and modify that?

Thx.

ppblaauw’s picture

Its not overriding the preprocess function from the module.
The $vars array is added as a reference @$vars.

It would just add variables to the $vars array.

Hope this helps you further, please let me know.

sinmao’s picture

Hmm... I couldn't quite get it to work. So If I wanted to add some variables ($variable_to_add) to the template:
views-slideshow-ddblock-cycle-block-content-vsd-custom-10p.tpl.php

I would include the following function in template.php:

function phptemplate_preprocess_views_slideshow_ddblock_cycle_block_content_vsd_custom_10p (&$vars) {
  $vars['variable_to_add'] = "Some value";
}

But that didn't seem to work.

ppblaauw’s picture

The preprocess function would be:

function phptemplate_preprocess_views_slideshow_ddblock_cycle_block_content(&$vars) {
  $vars['variable_to_add'] = "Some value";
}

or

function [Site theme name]_preprocess_views_slideshow_ddblock_cycle_block_content(&$vars) {
  $vars['variable_to_add'] = "Some value";
}

Replace [Site theme name] with the name of the theme you use for the site. (including the brackets)

Clear the cache after adding the preprocess function.

Hope this helps you further, please let me know

ppblaauw’s picture

Title: Adding custom variables to custom themes » Adding custom variables to custom themes (Fixed)
Status: Postponed (maintainer needs more info) » Fixed

Set status to fixed. Assume answer solved the issue.

sinmao’s picture

Hi,

Yeah, problem fixed. Thx.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.