smarty variable inside php -


i need call smarty variable inside php tag. added function .. 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          pm_embed_code, pm_meta         pm_embed_code.uniq_id = '". $video['uniq_id'] ."'         , 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 example:

{assign var="video_meta" value=$video_data}  {php} $metas = $this->get_template_vars('video_meta'); echo $metas['id']; {/php} 

get_template_vars assign

edit:

the actual problem was: calling function written smarty templating between {php}{/php} tags... doenst makes sense me still...

smarty_get_video_meta( array( 'video_id' => $video_data.id, 'key' => 'google' ), $this );

this how call function in template files in php.

in smarty:

{get_video_meta video_id=$video_data.id key='test'}


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -