I need call smarty variable inside my php tag. I added function also .. this is my smarty variable
{get_video_meta video_id=$video_data.id key='test'}
//resut = google
My Function
function smarty_get_video_meta($params, &$smarty)
{
global $video;
if (empty($params['uniq_id']) && empty($params['video_id']))
return '';
$video_id = 0;
if ($video['source_id'] == 0)
{
$sql = "SELECT item_id
FROM pm_embed_code, pm_meta
WHERE pm_embed_code.uniq_id = '". $video['uniq_id'] ."'
AND pm_embed_code.id = pm_meta.item_id";
if ($result = mysql_query($sql))
{
$row = mysql_fetch_assoc($result);
mysql_free_result($result);
$video_id = $row['item_id'];
}
}
else
{
$video_id = $params['video_id'];
}
if ( ! $video_id)
return '';
$meta = get_meta($video_id, IS_VIDEO, $params['key']);
return $meta[$params['key']];
}
php code
{php}
$url = $this->get_video_meta('test');
echo $url;
{/php}
Here is an example:
{assign var="video_meta" value=$video_data}
{php}
$metas = $this->get_template_vars('video_meta');
echo $metas['id'];
{/php}
EDIT :
The actual problem was: calling a function written for smarty templating between {php}{/php}
tags... Which doenst really makes sense to me but still...
smarty_get_video_meta( array( 'video_id' => $video_data.id, 'key' => 'Google' ), $this );
This is how you would call the function in template files in PHP.
In smarty:
{get_video_meta video_id=$video_data.id key='test'}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.