Jump to content

separation templates - business logic


helmut2509
 Share

Recommended Posts

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

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
 

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...