Variables to use in theme templates

1 reply [Last post]
Joined: 05/06/2009
Points: 4

I'm ready to build some custom templates in which to display the Kaltura player, but I can't find any hints as to what variables to use to call the player in the templates.

Contemplate shows this as a possible variable to use:

$node->field_cdnvideo[0]['view']

But all that does is output a value that looks like this:

[kaltura-widget media_type="video" entry="xvxm640iug" size="large" width="410" height="364" /]

What variable(s) should I be using to display the Kaltura player in my custom theme template?

Joined: 05/06/2009
Points: 29

Hi bob,

there's no direct variable in the node to do it, but you can use kaltura_replace_tags($content) to convert the string into html.

Here's how i did it:

Custom HTML for the video player

Create the preprocess node function with a reference to the vars variable as a parameter in template.php

by calling preprocess_node, the variable will be available to our node_{node_type}.tpl.php file

function call is as follows

function theme_preprocess_node(&$vars){

by specifying the & in &$vars, we take a reference to the vars variable in, and so do not have to return anything

Here we want to create the html for the kaltura player, so

we get the width and the height from variables set in the admin section

$width = variable_get('kaltura_video_entry_width', '410');
$height = variable_get('kaltura_video_entry_height', '364');

get the entry Id from the node, then
$entryId = str_replace(',', '', $vars['field_video'][0]['value']);

format as per the format required by the kaltura module

$return = '[kaltura-widget media_type="'. $media_type .'" entry="'. $entryId .'" size="large" width="'. $width .'" height="'. $height .'" /]';

call the replace tags function to get the required html and save it to the myPlayer variable that we'll access later in our node.tpl.php file

$vars['myPlayer'] = kaltura_replace_tags($return);

The variable $myPlayer should now be available in your node.tpl.php file

Hope this helps