Here’s a little view helper to display a tag cloud. All you have to do is supply an array of tags, with the tag name being the index and how many times it’s used as the value, and the url you’d like the tags to go to.
Archive for the 'PHP' Category
I like the filtering capabilities of the Zend Framework, but for some reason there doesn’t seem to be a string to title case filter (though there is a string to upper and string to lower). So here it is:
Do you have a database with foreign keys and just wish you could have something automatically create your ZF models from it? Well, today that was me. So as a little proof of concept, this is the code I came up with to do it for me…
But before we get to that, a few caveats:
- It’s just a proof of concept
- The output needs updating for proper reference names, etc.
- Outputs everything to screen in one go and doesn’t save the files.
However, it might be handy to someone, so I post it up for your comments.
Continue reading ‘Auto generating basic models for a Zend Framework app’
For those that don’t know by now, version 1.5 of the Zend Framework is now out in preview release. Congratulations to everyone who has had apart in getting out this release - from programmers to documentation writers to project managers!
There are a lot of very interesting updates and new features. Some notable ones are the inclusion of Zend_Form, Zend_Layout, OpenID and LDAP adapters for authentication, Technorati web service, as well has handy tweaks Zend_Db_Table such as being able to directly access the select object.
As it’s a preview release the code isn’t intended for production systems just yet, though I hope the time frame for getting it to stable release is short enough so that I can use it soon, but long enough to work out any major kinks.
Here's a small function that will allow you to force a file download.
-
/**
-
* Force a file download via HTTP.
-
*
-
* File is required to be on the same server and accessible via a path.
-
* If the file cannot be found or some other error occurs then a
-
* '204 No content' header is sent.
-
*
-
* @param string $path Path and file name
-
* @param string $name Name of file when saved on user's computer,
-
* null for basename from path
-
* @param string $type Content type header info (e.g., 'application/vnd.ms-excel')
-
* @return void
-
* @access public
-
*/
-
/* public static */ function download($path, $name = null, $type = 'binary/octet-stream')
-
{
-
echo 'File download failure: HTTP headers have already been sent and cannot be changed.';
-
exit;
-
}
-
-
exit;
-
}
-
-
-
exit;
-
}
Very easy to use, too! Here are some examples of how you might call the function:
-
download('./myfile.txt');
-
-
download(__FILE__, 'a file for you.php');
-
Here's a simply view helper for the Zend Framework that can be used to display image tags. It checks to see if the image file exists and if not then it'll use the data url scheme to output a very simple image that, ironically, says 'NO IMG' on it.
Please note, though, that I've only seen Firefox support this scheme, as wonderful as it is!
Continue reading 'Simple image view helper for Zend Framework'
The first day of talks is now over, and all in all I found it quite informative. so what did I learn?
Right now I'm sitting at a table with the likes of Cal Evans, Ben Ramsey, Sara Goleman, and Derick Rethans - all big players in the PHP world. And here I am, lowly ol' me who does a bit of PHP at work. Wow. I feel a little starstruck (in a geeky kinda way), I have to admit!
OK, to be honest, I'm not saying anything, but, hey! I'm here. It's a start. ![]()
Today I'm flying to Atlanta for the php|works conference. I am really looking forward to this as there seem to be quite a number of good talks - so many, in fact, that I had a hard time deciding which tracks to attend.
As part of this conference package I also had the opportunity to do the Professional PHP online course run by php|architect. I enjoyed that, and learned a fair bit, so I'm hopeful for the conference. ![]()



