Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Some of you may remember that I was originally a little skeptical of ZF. Well, I've spent a few days working with it and so far I've been very impressed with how easy it is to enhance. This is the sign of a very well-designed system. For the curious (bored), here's a quick breakdown of what I've done w/ my ZF engine:
My view renders using Smarty. I hate embedding PHP in a view. That whole <?php $this->escape ( $this->blah ); ?> crap is really tedious and ugly once you have any significant content. If you're gonna throw all that PHP in the view, you might as well just keep it in the controller as far as I'm concerned. Smarty-style tags, ie. {$blah}, are so much cleaner. Or better yet, {$blah|strip_tags|capitalize|truncate:10}. Very cool and it's a lot friendlier to HTML designer types.
I also added a new abstract class called MyZend_View_Helper. This overrides my normal view class and can be used to build special helpers. My Helpers are small, little blocks of code that render something for a view/layout. They are put in a special folder at the root of the application called, not surprisingly, "helpers" and can be sucked into any view or layout with a custom Smarty function like so:
[syntax="smarty"]{helper name="LayoutHelper" method="DisplayMenu"}Code: Select all
<body>
<h1>BPopp Sanctuary</h1>
<div id="nav">{helper name="LayoutHelper" method="mainMenu"}</div>
<table width="100%" cellpadding="10">
<tr>
<td width="650" valign="top">
<div id="content">
{$CONTENT}
</div>
</td>
<td valign="top">
<p>{helper name="LayoutHelper" method="identity"}</p>
<p>{helper name="LayoutHelper" method="quoteOfTheDay"}</p>
<p>{helper name="LayoutHelper" method="hallOfFame"}</p>
</td>
</body>
Code: Select all
function renderViewToLayout ( $view=null, $layout=null, $area="CONTENT" );
function renderToLayout ( $string, $layout=null, $area="CONTENT" );
function renderLayout ( $layout );Code: Select all
...
$this->renderToLayout ( '<h1>Hello World!!</h1>', 'main', "CONTENT" );
$this->view->rows = $articleObject->FetchRows();
$this->renderViewToLayout ( 'articles/index.tpl', 'main', "CONTENT" );
$this->renderLayout ('main');Code: Select all
class LayoutHelper extends MyZend_View_Helper
{
public function quoteOfTheDay()
{
Zend_Loader::loadClass('Quote');
$object = new Quote();
$object->UseRelationship ( "creator" );
$object->AddOrderBy ( "RAND()" );
$object->SetLimit ( 0, 1 );
$this->assign ( "rows", $object->FetchRows() );
return $this->render ( "quotes/view.tpl" );
}
}feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]