Return to Snippet

Revision: 29208
at July 23, 2010 21:22 by jiewmeng


Updated Code
// article.phtml
<article>
    <header>
        <h2><a href="javascript:;"><?php echo $this->header; ?></a></h2>
    </header>
    <?php echo $this->body; ?>
</article>

// view script
// basic usage with array
echo $this->partial("article.phtml", array(
  "header" => "This is a single post ...", 
  "body" => '<p>rendered via <code>$this->partial()</code></p>')
);

// passing an object with public properties
$article = new stdClass();
$article->header = "This is a \$article->header";
$article->body = "This is the \$article->body ... ";
echo $this->partial("article.phtml", $article);

// basic usage of partialLoop() with array
echo $this->partialLoop("article.phtml", array(
  array(
    "header" => "This is a title", 
    "body" => '<p>This is the body. rendered 1st post rendered via <code>$this->partialLoop()</code></p>'),
  array(
    "header" => "This is a 2nd article", 
    "body" => "<p>This is the body</p><p>some more content</p>"),
  array(
    "header" => "Then the 3rd", 
    "body" => "<p>This is the body</p><p>yet more content</p>")
));

Revision: 29207
at July 23, 2010 21:18 by jiewmeng


Initial Code
// basic usage with array
echo $this->partial("article.phtml", array(
  "header" => "This is a single post ...", 
  "body" => '<p>rendered via <code>$this->partial()</code></p>')
);

// passing an object with public properties
$article = new stdClass();
$article->header = "This is a \$article->header";
$article->body = "This is the \$article->body ... ";
echo $this->partial("article.phtml", $article);

// basic usage of partialLoop() with array
echo $this->partialLoop("article.phtml", array(
  array(
    "header" => "This is a title", 
    "body" => '<p>This is the body. rendered 1st post rendered via <code>$this->partialLoop()</code></p>'),
  array(
    "header" => "This is a 2nd article", 
    "body" => "<p>This is the body</p><p>some more content</p>"),
  array(
    "header" => "Then the 3rd", 
    "body" => "<p>This is the body</p><p>yet more content</p>")
));

Initial URL

                                

Initial Description
`article.phtml` looked up in `views/scripts` by default. \r\n\r\ncan use `$this->partial(\"blog/article.phtml\", array(...))` to look for it in the `views/scripts/blog` folder too

Initial Title
Zend Framework: Partials

Initial Tags

                                

Initial Language
PHP