Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Difference between a partial and a layout? And when to use what?

I am trying to learn phalcon and have been writing up an application while doing so. I am now at a stage where I need to separate common elements from a view. I read up on partials and layouts documentation. What I am confused with is which to use when and what’s the difference between the two? Any help is appreciated. Thank you.

edited Aug '14

Layout is a layout.... for set header and footer and partials is for example:

Layout can be:

  1. Layout for blog
  2. Layout for homepage etc.

And partials it could be:

  1. blog post
  2. Part or element or some widget or sidebar of homepage

For examle in index.phml of my index ( my homepage)

<div class='content'>
   <div class='left'>
       {{ partial('menu/main') }}
       {{ partial('widgets/tagcloud') }}
   <div class='right'>
     // here is the content

So you can partition some block of HTML or FULL elements to the partial and in the template you can include just the partial code for save lots of lines with repeating the code.