Albert Rosa It's not what you say it's how you say it

15Apr/110

Tutorial: Managing Cron Jobs with PHP

No Gravatar

Again reading through some RSS and came across another cool tutorial for Managing Cron Jobs with PHP 5.3+.

Check it out: http://net.tutsplus.com/tutorials/php/managing-cron-jobs-with-php-2/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+nettuts+%28Nettuts%2B%29&utm_content=Google+Reader

Let me know what you think.

 

Share
13Apr/110

Creating View Helpers for Zend Framework

No Gravatar

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.

Share
28Oct/100

Ant Scripting – Introduction: Slides from CodeIgniter Meeting on 10-27-2010

No Gravatar

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 :-D .. 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:

Share

Albert Rosa is using WP-Gravatar