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 way to implement smarty on existing PHP/MySQL site

 
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
Neolux
Smarty n00b


Joined: 07 Sep 2003
Posts: 2
Location: Melbourne, Australia

PostPosted: Sun Sep 07, 2003 4:44 pm    Post subject: Best way to implement smarty on existing PHP/MySQL site Reply with quote

Hi there.

Came across smarty from a discussion on Wikipedia. I read about 5 minutes and decided that this was something I'd love to include on a site I have in development at the moment.

Thing is, that I've invested a significant amount of time into coding and designing, so I would like to know the best way to migrate everything into smarty without breaking anything. (Site is in Live Beta at the moment).

Obviously, it will take time to learn the smarty syntax, but I would love to separate design from programming, so smarty seems to be the solution.

Also, I would like to be able to offer themes in the future, but this is not important at this stage.

Has anyone migrated a live site, as a newbie to smarty, and how did you do it successfully?

Thanks in Advance,

GM
Back to top
View user's profile Send private message Visit poster's website
wvdploeg
Smarty Rookie


Joined: 05 Aug 2003
Posts: 19

PostPosted: Sun Sep 07, 2003 9:08 pm    Post subject: Reply with quote

Guess the best way is to install it all on a local computer, not on your life site. The secondbest way is to start experimenting in some subdirectory of the 'life site'.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun Sep 07, 2003 10:32 pm    Post subject: Reply with quote

Hi Neolux.

Good to hear that you are thinking of Smarty as part of your solution--you came to the right place for some help!

In terms of the migration that you refer to, it is difficult to respond without having an understanding of how you are doing things now. I sense that perhaps you have not presently separated your application logic from your display code?

If that is the case, I suggest that you may have luck if you start to refactor your application code so that it is increasingly modularized and distinct from your display code. As you pull your application code out of your display code, you are left with simple calls back into your application objects (or modules or whatever you choose). At that point it should be fairly simple to make a full blown switch by rewriting your display logic as Smarty templates.

Using Smarty doesn't automatically fix your design problems for you, but it does give you a nice toolset so that you can implement thoughtful designs. Perhaps you should take a small portion of your app (say one or two pages) and try to transition those alone for a test. Have a browse around the forums as well. I've seen a lot of good ideas presented on the forums so do scan a bit. You may also be interested in reading some articles that address Smarty as an abstraction layer (see the Articles forum and the main Smarty website for more on that).

Cheers and good-luck!
Back to top
View user's profile Send private message
Neolux
Smarty n00b


Joined: 07 Sep 2003
Posts: 2
Location: Melbourne, Australia

PostPosted: Mon Sep 08, 2003 6:42 am    Post subject: Reply with quote

Thanks for the replies folks,

I guess the way things are at the moment, are that I have a function library where most of the intensive programming is done, and generally I display pages based on the library functions and some functions within the actual page.

Testing locally is not really a good option, because I can't access my database locally.

Can I install smarty and have it working in the background, then gradually change my code to smarty code?

Installation shouldn't break anything already there should it? Just download, install, and then start playing?

Cheers,

GM.
Back to top
View user's profile Send private message Visit poster's website
CirTap
Smarty Pro


Joined: 04 Jun 2003
Posts: 106

PostPosted: Mon Sep 08, 2003 11:47 am    Post subject: Reply with quote

Hi,
Neolux wrote:
Can I install smarty and have it working in the background, then gradually change my code to smarty code?

If your "library" code allows you to do so (it sounds like), it should be possible regarding the "logic" parts, but it's a bit tricky (and messy), to mix "hardcoded" html output with template output.
You'd do best to follow boot's advice and do your try outs in a subdirectory, starting with a few simple pages until you're familiar with Smarty as a PHP class, it's options, plug-ins, paths etc. and the template syntax, then break down the pages in individual bits and pieces.
You may also create a subdomain as a mirror of your current site and do all the testing and migration steps over there.

Neolux wrote:
Installation shouldn't break anything already there should it? Just download, install, and then start playing?

Don't forget configuration/b]!
Smarty won't interfere with you existing installation unless you have the same files and classes <g>. Just copy its folder where you have your other library files (include path?).
Configuring the [B]input and output directories
for Smarty (safe_mode yes/no, CHMODs, cache on/off etc. pp.) may sometimes cause some trouble depending on your server environment and how "smart" your own directory structure is designed.
Again, boots already pointed it out: browse the forum and ... RTFM Wink

Have fun,
CirTap
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