Handling different page types in a CMS

Tags:

I’ve often been asked whether my CMS is public, whether the code is available, etc. – the answer at the moment is no, but information about it is public… so for your reading pleasure, here’s some information on how I’ve handled the issue of different page types. All pages share some details, such as name, id, location in the page …

Complex custom elements in Zend_Form

Tags:

I’ve sometimes needed custom elements in forms – say two fields for inputting two numbers. For something simple like that, adding two separate elements usually suffice, but when one of my clients wanted a field with multiple checkboxes, but only specific pairs could be selected, it started getting too complex. Until then, I had kind of avoided making those custom …

ModelForm developments

Tags:

I’ve been reworking the ModelForm class for ZF a bit. Earlier this year, I discussed porting it to use Zend_Db_Table with Matthew Weier O’Phinney, for using it with Zend Framework. I initially had done some checking on Zend_Db_Table, and some small code changes to modify the class to use it instead of Doctrine, but I ran into some issues. Now, …

How to CSRF protect all your forms

Tags:

CSRF, or Cross-Site Request Forgery, is a vulnerability very common in websites. In short, it means that if you have your site at foo.com, and an attacker at badguy.com can display a form similar to one of your site’s, and make users on his site submit the forms on your site, possibly without their knowledge. This can be dangerous, especially …

Zend Framework – good for beginners or not?

Tags:

I’ve heard some inexperienced PHP programmers say that Zend Framework is confusing to them. Until today, I have agreed: Zend Framework has a lot of classes and some of them are quite complex (such as Zend_Form). But does that actually make it more difficult for inexperienced programmers than other frameworks?

PHP tip: How to make a file downloadable through your script

Tags:

This seems to be a relatively common question on #zftalk nowadays, so here’s a quick wrapup! The traditional plain-PHP way $file = file_get_contents(’some.zip’); header(’Content-Type: application/zip’); header(’Content-Disposition: attachment; filename="some.zip"’); header(’Content-Length: ‘ . strlen($file)); echo $file;$file = file_get_contents(‘some.zip’); header(‘Content-Type: application/zip’); header(‘Content-Disposition: attachment; filename="some.zip"’); header(‘Content-Length: ‘ . strlen($file)); echo $file; The Zend Framework controller way //this is inside an action in one of …

Making a PDF generator class using Zend_Pdf

Tags:

There are some expensive libraries that you can use to generate PDF files… but why bother with them, when there are good free alternatives like Zend_Pdf? In three steps, you can generate a fancy report: Create a PDF template Insert data to template with Zend_Pdf Profit $$$ Since this is a quite repetitive task, let’s also create a PDF generator …