How do I manage a Smarty Website?

I've inherited a website coded with Smarty PHP and My SQL. I am an ASP programmer though I am somewhat fluent in PHP as well. I have never used Smarty before. I have reviewed the website crash course which makes it seem very simple to begin a website using Smarty. However if you were to begin with an already existing website that was coded with Smarty, how do you begin to manage it?

The homepage calls an include file which then calls 3 more include files which then each of these include files call 30 + more include files which within these contain 30+ functions with one of them being "get homepage". Amongst all these includes and functions, how do you do the simplest tasks such as change a homepage image? How do you manage all of the includes and functions to know where a piece of code is to edit??? Not to even mention all of the database includes and functions throughout all of these includes.
There must be some type of management system of all these includes, templates and functions to see where a little section on a webpage may be edited.

Please help. I need to know how to manage an existing Smarty website when I have no history of it's making. Thank you.
PEChartsAsked:
Who is Participating?
 
Julian MatzConnect With a Mentor Joint ChairpersonCommented:
If your homepage is made up of 15 template files, you should be able to see this in the main template file. For example, a standard homepage tempalte might look like this:

{include file="header.tpl"}

{include file="sidebar.tpl"}

<!-- your homepage content -->

{include file="footer.tpl"}

In this example template, there are 3 included templates - a header, a sidebar, and a footer. Obviously if you wanted to change the site's header, then you would open up the header.tpl file for example. Apart from that though, editing Smarty templates is more or less just like editing standard HTML pages with the advantage of being able to use the additional tags - the variables Smarty gets from the PHP scripts.

If PHP pulls product information from a database, then all that information should be available to Smarty, so no, you wouldn't need to edit any PHP. It's totally up to you to take that information and display it any way you like by using Smarty tags/variables, (x)HTML, and CSS styles.

By using the {debug} tag inside your templates, you will get an idea of what variables are available for you to work with. That way you don't even need to touch the PHP scripts (unless of course you're trying to change functionality or add Smarty variables).

There's no reason why you couldn't use Frontpage or Dreamweaver in split view.

I use a commercial application for which I paid a license fee to the developers. All the core PHP files are encoded, so even if I wanted to, I couldn't make any changes to the PHP. However, I have complete control over the look and layout of the application's frontend because it has a Smarty template system. All the template files are inside a directory called "templates", and the individual templates are named "header.tpl", "footer.tpl", "homepage.tpl", "login.tpl", "logout.tpl" and so on... To make changes to the look and layout, I can simply add my own HTML or change the existing HTML, and then edit the stylesheets accordingly. I make all these changes in Dreamweaver. Personally, I only work in code view. I've been coding for so long that I can now visualise the code and don't need a WYSIWYG editor. If I wanted to I could also work in design view or split view, but of course you might not get a proper representation if the template also uses include files. If I'm not sure which variables or information (e.g. from a database) are available to a specific template, then I use the {debug} tag to get a full list of variables and arrays/objects.

Hope this makes sense.
0
 
Julian MatzJoint ChairpersonCommented:
To start off with, I would probably use the following tag in your smarty templates to check what smarty variables are available to you out of the box...

{debug}

^ If you include this tag within your templates, it will open a popup window in your browser when you open the appropriate page. This popup window shows you all the variables available to you for that template.
0
 
ProfessionalDataSystemsCommented:
Is there a software for managing smarty?? Something that maybe uses split-screen, view/code like dreamweaver, frontpage, etc, that connects directly to the site where you may view your homepage in the view section and then click on an area on that page to see where the code for this, among all of the template and include files for example?

Here is an example: Homepage.php contains code that calls a function get homepage() and includes a file. The include file then includes 15 more files, contains 5 more functions. In the 15 include files, there is a file that contains 30 more functions and several more include files.
So.... how do I change the homepage logo? Is Smarty a system tha requires me to sift through each and every include file, template and function manually, using Notepad, to find the one piece of code to change a logo?? or is there some sort of application software or ideal method of managing a website that was built with Smarty?
0
 
Julian MatzJoint ChairpersonCommented:
One of Smarty's main functions is to separate programming from design. This means a PHP developer and a web designer can work independently of eachother. To change the design and layout you don't need to modify any PHP files.

>> Is Smarty a system tha requires me to sift through each and every include file,
>> template and function manually, using Notepad, to find the one piece of code
>> to change a logo??

It's exactly the opposite. As mentioned above, Smarty replaces the need to go through any PHP files. Dreamweaver works absolutely fine for editing Smarty sites, although Notepad will work too. To change the homepage logo for example, you would simply open the Smarty homepage template and modify the HTML. Smarty templates are usually stored in a directory called "templates" and have a ".tpl" extension.

So, to sum it up, with a Smarty site, you would only need to edit the PHP files if you need to change functionality on your site, and the Smarty templates are for changing visual presentation, layout, design, etc.

0
 
PEChartsAuthor Commented:
Assuming the homepage is made up of about 15 template files, then what?  What if PHP is pulling info from a database for display (like display a product)? Then you must edit PHP for design too, no?

Thank you Julian for the explanation of how Smarty should work however I need direction on where/how to start managing a smarty site I did not build.  Like for example, what software should I use, how should that software work with managing all these files, will I be able to use split-view like in Frontpage for example, having the page displayed at the bottom with the code up top and be able to see where I need to edit code for a particular section of the webpage?

Or - is this ALL manual; Do I need to open every template file and 'figure out' which is which? Or go through all 40 include files and functions and figure out manually what templates go where, which code is for what, etc, etc.

There must be some tool or application that helps make managing a smarty site efficient, no??? Can someone maybe walk me thru how they themselves would edit a particular piece of code on a site page that was built with smarty? Assume its a complex, database driven site.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.