Thursday, December 13, 2012

Difference between Blocks and templates

Why do we need a block? And where do we define it?

I think templates are flexible, and I use them as partials and "blocks".
Therefore I'm curious about how to use a block.

For example, I could do this (if I'm not wrong):

Views/index.ctp

<?php echo $this->element('someBlock'); ?>

Then in Views/Elements/someBlock.ctp

<div>    //some layout    <?php echo $this->element('someBlockContent'); ?>  </div>

Then finally in Views/Elements/someBlockContent.ctp

<div>      <p>This is someBlockContent's content</p>  </div>

Nested templates works the same as a block?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: