kid_drew Posted September 12, 2006 Share Posted September 12, 2006 Ok, so I'm a veteran programmer beginning to venture into the world of PHP. I'm looking for an idea of how people go about structuring their files in large projects. I've heard of people keeping their PHP and HTML code separate, and I really don't understand how that is done seeing as how so much is done inline. Does everyone just use smarty templates?What about file structure? Does everyone have a typical header/body/footer structure where they include/require header and footer files in every page and fill in the content in between? Quote Link to comment Share on other sites More sharing options...
btherl Posted September 12, 2006 Share Posted September 12, 2006 Yep, Smarty templates. Once you've started you won't be able to stop :)Headers and footers are usually a good idea. But it depends a lot on your application. It might make sense to abstract other things out too. If you're using Smarty, you can have code in your "display a page" function that adds in the header and footer for every page. Then there's no need to repeat that code everywhere. If some pages don't use the standard header/footer, you can set a "don't load header/footer" variable before calling the display function.The system I work on currently uses apache to rewrite requests like /page.html to use the script page.php and the Smarty template page.html, and call the function page() to get the Smarty variables. Then to make a new page you just create the template and the associated file, and off you go.Smarty templates include foreach loops, captures (eg, capture your pagination links and print them at the top and bottom of the page with only one set of code, but all still in the templates), and other nifty stuff. Quote Link to comment Share on other sites More sharing options...
radalin Posted September 12, 2006 Share Posted September 12, 2006 smarty is hard. It's not only a template system but also it has its own syntax and abilities. I do not like it a lot. Because it has too many features about logical things in html files. If there are web designers and web programmers things should be different. And none should do others job. But with smarty, a designer can write it's own logical queries, which I would never prefer. I use pear's html_template_it which is quite good and only a template system. It's very easy to learn too. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.