Tomorrow morning, I get to demo our first Zend Framework powered application to the MD of the client's company. I'm dealing with the IT director there, so it's a little nerve-wracking to be presenting to the boss-man!
The demo is going to go well as it's a pretty damn good application.
Tomorrow I'm gonna write an Active Record type class to make dealing with the database easier. Zend_Db_Table just doesn't cut it!
I have a real world project to deliver that will be based on the Zend Framework, so I'm actually putting in time to get a system that works for me.
Some of the work I'm doing, I've decided to release under the same license as the Zend Framework and I've decided to use the name AkCom. I was using Akrabat, but decided that it's too generic for me and I might have other plans for it in the future :)
AkCom mainly exists to provide a place for me to put my extensions to the Zend Framework in order to enable me to write applications more easily. No doubt it'll grow over time!
An extension of Zend_Controller_Action that creates views automatically for use in the action. Upon destruct, it renders the view. Recent impovements are based on the ideas of Marcus
A simple router that picks up controller and action from the $_GET and $_POST arrays. It allows for use of Zend_Filter_Input to hold $_GET and $_POST and also allows for controllers to be in different directories based.
With the help of Cliff, I've finally got a publically accessible subversion repository online at http://svn.akrabat.com!
The first project with actual code in it is my Dynamic Javascript Tabs. I've updated the trunk to include the change suggested by Samio so that the "activation" code is not part of the js file and is not part of the htm file.
An question about iteration, arrays and Zend_Config was posted to the Zend Framework's mailing list by Troy Marker. I thought I'd repeat it here as the solution shows how flexible Zend_Config can be.
At a guess, Troy is building a menu type system, but that's by-the-by for the problem.
First of all, a recap on Zend_Config's load system; you must always load one of the top level element's from the file. In the case of this particular XML file, you would have to load <lists>. This is accomplished using the php code:
$config = new Zend_Config(Zend_Config_Xml::load('test.xml', 'lists'));
Having loaded a top level element, it follows that the $config now "points" to elements inside this element. Thus we can access the information at
using:
$link = $config->root->line1->link
and $link will contain the string "/index/show/gallery/cars/".
All nice and easy :)
Iteration is also supported by Zend_Config, so if we do:
foreach($config->root->line1 as $key=>$data)
{
echo "$key = $datan";
}
Then the output is:
link = /index/show/gallery/cars/
text = Cars
At this point when you realise that you need an array of arrays as Troy does, you'd be tempted to use a nested foreach loop to iterate over all the elements to create the array:
This solves Troy's problem completely! However there is another way! (obviously, otherwise, this entry would be pointless!) Zend_Config provides a helper function for exactly this type of problem: asArray().
asArray() does exactly what it says on the tin: it gives you an array from your config key. This lets us lose one of the foreach loops:
and a dump() of $allLines is exactly the same as above.
As this array is destined for Smarty, it's likely to be processed using Smarty's {foreach} construct. One useful thing about {foreach} is that it doesn't need a zero indexed array, any array will do. Thus we can probably get away with this code:
As you can see, it's not quite the same as before. This time each element's key in $allLines is now the name of the enclosing element of the XML file. As I said, this probably doesn't matter in 99.9% of cases. Going back to Troy's GetList1() function, we can replace it with:
public static function GetList1($rlist)
{
return Zend::registry('lists')->$rlist->asArray();
}
Just in case anyone missed it, Zend Framework 0.1.4 is now out! This is an important release as it has Zend_Config in it, along with a host of other stuff :)