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
Comment #1
ppblaauw commentedyes, 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.
Comment #2
sinmao commentedHi 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.
Comment #3
ppblaauw commentedIts 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.
Comment #4
sinmao commentedHmm... 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:
But that didn't seem to work.
Comment #5
ppblaauw commentedThe preprocess function would be:
or
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
Comment #6
ppblaauw commentedSet status to fixed. Assume answer solved the issue.
Comment #7
sinmao commentedHi,
Yeah, problem fixed. Thx.