Tutorial: Managing Cron Jobs with PHP
Again reading through some RSS and came across another cool tutorial for Managing Cron Jobs with PHP 5.3+.
Let me know what you think.
Creating View Helpers for Zend Framework
In a recent project I have worked on, there were a lot of forms that needed to be created but at the same time they each had similar styles. Unfortunately it wasn't as simple as just adjusting css and manipulating the pre / post tags on the form elements.
Naturally we would use Zend_Form to create the form completely as I did, but the view portion of it needed to be customized. I created a view that had the form exactly how the design had requested in pure html. I made sure the elements were matched with those expected elements in Zend_Form.
sample view:
<form method="post" action="/form/demo/">
<table>
<tr>
<td><label for="label">Label here <span class="required">*</span></label></td>
<td><input type="text" name="field" value=""/></td>
</tr>
</table>
</form>
Now I am aware of how to adjust this in zend form in order to maintain the usability but for a challange I wanted to make a view helper that encapsulated the whole tr row label, and field information all in one call. Is this nice to do no not really, but can it be done yes it can.
I created a helper for the section:
class Demo_View_Helper_Textbox extends Zend_View_Helper_Abstract
{
public function Textbox($name, $value, $attribs)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info);
$endTag = ' />';
if(($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()){
$endTag = '>';
}
$required = $attribs['required'] ? '<span class="required">*</span>':'';
$xhtml = '<tr><td><label for="'.$this->view->escape($name) . '">' $this->view->escape($attribs['Label']) . ' ' . $required . '</label></td>';
$xhtml .= '<td><input type="text" name="'.$this->view->escape($name) .'" id="'.$this->view->escape($id) .'" value="'.$this->view->escape($value) .'" .$this->_htmlAttribs($attribs) . $endTag .'</td><tr>';
return $xhtml;
}
}
Now we can just call in the view
<form method="post" action="/form/demo/">
<table>
$this->textbox('demo' , '', array('Label'=>'Demo Label', 'required'=>true));
</table>
</form>
and we get the desired code display.
Again there are different ways to get this done in different maners within Zend this is jus something quick and simple for Zend_Helpers.
Ant Scripting – Introduction: Slides from CodeIgniter Meeting on 10-27-2010
Hey peeps, bellow you will find last night's CodeIgniter Slides. It was a good event, many people many new faces. I myself still stumbled over the presentation, I really should try to make more of an effort to practice my presentation. I do hope to also.
Next Months meeting will be catered by Your's Truly
it's about time we give our loyal members some feed
.. and I am planning on making a true CodeIgniter NYC home I'll add it to the multiple task I have given myself.
without further ado here ya go: