Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

How can I assign variable to new variable?? Help!

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
chichongo
Smarty n00b


Joined: 30 Apr 2014
Posts: 1

PostPosted: Wed Apr 30, 2014 11:14 am    Post subject: How can I assign variable to new variable?? Help! Reply with quote

Hello

I'm new to smarty, wanted to know if I can fetch the value of a variable that is displayed on a .tpl file, from a plugin, then use this value and return it to the .tpl to update the plugin.

this is what I'm trying to achieve, I'm getting data from an XML file which works, but I need the variable from .tpl file for the correct sorting to be done.

please note the below code is not a correct plugin for smarty.

Code:


<?php
function smarty_function_picloader($params, &$smarty,  $template)
{

$all_urls = array('http://data.domain.com/xml/media/This needs to return productcode value from a variable in template/');

foreach ($all_urls as $stockList) {
    $stockList = simplexml_load_file($stockList, "SimpleXMLElement", LIBXML_NOCDATA);
      foreach ($stockList->products->product as $prod) {

               $screenshot =  $prod->trailers->trailer;
               print "<div class=\"thumbs\" style=\"width: 620px; height: auto; display: block; padding: 10px;\">";
               foreach ($screenshot as $shots){
                  $pics = $shots->still;
                  print "<a class=\"fancybox\" data-fancybox-group=\"gallery\" href=\"$pics\" title=\"This needs to return the title value from a variable in template\">
                  <img src=\"$pics\" width=\"100px\" height=\"auto\" style=\"border: solid 1px #f1f1f2; float: left; padding: 10px;\" alt\"\">
                  </a>";
               }
               print "</div>";
               print "<div style='clear:both;'></div>";      
      }      
   }         
}

?>

Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Fri May 02, 2014 11:50 am    Post subject: Reply with quote

See http://www.smarty.net/docs/en/api.get.template.vars.tpl
It can be called as a method of the template object which is passed to the plugin.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP