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

best migration info

 
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
cjxxi
Smarty Regular


Joined: 03 Aug 2007
Posts: 40
Location: Fort Worth,Texas

PostPosted: Sun Feb 13, 2011 5:25 am    Post subject: best migration info Reply with quote

//readme file summary read.

Is there any useful information available or can someone tell - - about how to migrate smarty from 2.x to 3?.

I've been watching all the betas and RCs and been waiting for a stable release of smarty 3.

I have a class called template which extends the smarty class and puts to use some of the php magic methods.


One of the observation I noticed that is that smarty does not longer use all variables as global to all templates. This makes the process a bit tricky for these that have already running the code implementing it in such way.

Here is the class extension, It was cleaned to just reflect the current example.

Code:
//$smarty_version = "2.6.26";
$smarty_version = "3.0.7";
require_once "library/Smarty-$smarty_version/libs/Smarty.class.php";
class template extends Smarty {

   function __set($setting,$value)
   {
      if(is_array($value)) {
         foreach($value as $s =>$v) {
            $this->_tpl_vars[$setting][$s] = $v;
         }
      } else  {
         $this->assign($setting,$value);
      }
   }
   
   function __get($setting)
   {
      return (isset($this->_tpl_vars[$setting])? $this->_tpl_vars[$setting]:null);
   }

}


Now, I noticed that Smarty now treats new variables as objects.

How does this play with the templates?. I also noticed the scope might have changed. And the usual "assign" method, is not longer viable as perhaps other might be as I saw there is a new "assignGlobal", which I assume takes over.

All these are really huge changes, that fundamentally will need us to make changes to a bulk of the existing code in our projects, to successfully migrate.


Now, out of the box, just downloaded a copy of the latest smarty and it not properly ran, I will smart a new topic for this error as does not relate to the above topic.
_________________
CJAX THE PHP AJAX FRAMEWORK AT CJAX.NET
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sun Feb 13, 2011 1:39 pm    Post subject: Reply with quote

Read the SMARTY2_BC_NOTES and README files that come with the Smarty 3 distro. The documentation is a good start too. It isn't all that different. Don't assume assign() is gone just because you don't see it in the top level class file.
Back to top
View user's profile Send private message Visit poster's website
cjxxi
Smarty Regular


Joined: 03 Aug 2007
Posts: 40
Location: Fort Worth,Texas

PostPosted: Sun Feb 13, 2011 3:48 pm    Post subject: Reply with quote

mohrt wrote:
Read the SMARTY2_BC_NOTES and README files that come with the Smarty 3 distro..

That is what the very first line of the post means. Actually I had looked the read me, and looked the SMARTY2_BC after I posted this.



mohrt wrote:
It isn't all that different. Don't assume assign() is gone just because you don't see it in the top level class file

Never said it was gone. What I said is it is fundamentally changed.
_________________
CJAX THE PHP AJAX FRAMEWORK AT CJAX.NET
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
U.Tews
Administrator


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

PostPosted: Sun Feb 13, 2011 6:08 pm    Post subject: Reply with quote

Nothing has changed for existing Smarty2 appilcations on assign(), fetch()
and display(). The major changes are under the hood.

You can use the following setter/getter
Code:
   function __set($setting,$value)
   {
         $this->assign($setting,$value);
   }
   
   function __get($setting)
   {
      return $this->getTemplateVars($setting);
   }

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