The Definitive Guide to symfony | Chapter 7 - Inside The View Layer | symfony | Web PHP... - 0 views
-
<?php class newsComponents extends sfComponents { public function executeHeadlines() { $c = new Criteria(); $c->addDescendingOrderByColumn(NewsPeer::PUBLISHED_AT); $c->setLimit(5); $this->news = NewsPeer::doSelect($c); } }
-
<div> <h1>Latest news</h1> <ul> <?php foreach($news as $headline): ?> <li> <?php echo $headline->getPublishedAt() ?> <?php echo link_to($headline->getTitle(),'news/show?id='.$headline->getId()) ?> </li> <?php endforeach ?> </ul> </div>
-
// Call to the component <?php include_component('news', 'headlines', array('foo' => 'bar')) ?> // In the component itself echo $this->foo; => 'bar' // In the _headlines.php partial echo $foo; => 'bar'