helmut2509 Posted February 5, 2017 Share Posted February 5, 2017 Hello, I am just programming a pw application with user forms and a lot of data processing (getting data from webservice, sending to webservice etc..). Now I don't like to mess up the Html in the templates with business logic, I want I neat separation of concerns. Are there any *best practices* how to handle this with processwire? Link to comment Share on other sites More sharing options...
Zeka Posted February 5, 2017 Share Posted February 5, 2017 Hi Look through these links: http://modules.processwire.com/modules/template-engine-factory/ https://github.com/fixate/pw-mvc-boilerplate http://modules.processwire.com/modules/template-file-helper/ 1 Link to comment Share on other sites More sharing options...
qtguru Posted February 5, 2017 Share Posted February 5, 2017 Go with Smarty there's a module for Smarty it's what i use if you are familiar with Twig, ASP Master Pages and all it's similar let me post some codes 1 Link to comment Share on other sites More sharing options...
qtguru Posted February 5, 2017 Share Posted February 5, 2017 This is the main layout where other sub templates will be injected into plain.tpl <div class="header-container" id="header-container"> <!-- Site navigation --> {include '../elements/nav.tpl'} <!-- The title of the site --> </div> <div class="wrapper"> <div class="page-content"> <div class="post"> <header class="post-header"> <h1 class="post-title">{$page->title}</h1> <p class="post-meta">{$page->published|date_format:"%A, %e %B %Y"}</p> </header> <!-- Beginning Twitter sharing Large button --> <a class="twitter-share-button" href="https://twitter.com/share" data-related="twitterdev" data-size="large" data-count="horizontal"> Tweet </a> <!-- End of Twitter sharing button --> <article class="post-content"> {block name="content"}{/block} </article> <hr> Notice the block name "content" assuming a visitor navigates to my about page here is the file for the about view about.tpl {extends '../layout/plain.tpl'} {block name="content"} {$page->body} {/block} See how clean and easy it is 1 Link to comment Share on other sites More sharing options...
Zeka Posted February 5, 2017 Share Posted February 5, 2017 @Sephiroth What about caching and performance? Does Smarty module respect template cache settings or it has an own caching system? Link to comment Share on other sites More sharing options...
qtguru Posted February 5, 2017 Share Posted February 5, 2017 Yes it does there's a setting for caching and lifetime, I think it's using Smarty Caching only gives you an interface around it, here is the module http://modules.processwire.com/modules/template-engine-smarty/ Link to comment Share on other sites More sharing options...
helmut2509 Posted February 6, 2017 Author Share Posted February 6, 2017 thanks for all your suggestions. I also found out this: https://medium.com/@clsource/the-wire-render-pattern-806bf6d6097a#.82as32ldy which seems quite interesting. Now I will check and find out which solution suits my needs best... 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now