04 Aug 2008
I am evaluating zoop as a framework for us to use in some internal applications. I like what I have been able see so far. Howeve, I am also looking for a framework that supported metadata driven page flow, vs. something built into the template or the controller code.
I saw a "sequence" directory in the zoop release, but wasnt sure what it was and could find no documentation for it.
Could one of you tell me if it is a page flow component and if it is how it works?
thanks
keith
Getting Started Sequence Zone
The sequence component does exactly what you are asking for using an XML file to create the flow control. In the sequence folder you will find a sequence.xml should serve as an example for how to setup your xml.
Zoop use zones and pages to break up site content to help you understand the XML tags. Just to a give you a quick idea of how the XML relates to the corresponding Zoop URLs lets assume your site exists at http://www.null.com and the Zoop files are at the root of the Web Server folder. All of your zones will be accessible at http://www.null.com/index.php/zone and all of the pages in a zone will be accessible via http://www.null.com/index.php/zone/page. (Please note that the index.php can be removed via a proper .htaccess file or server setup.
To get started you need to add open the includes.php file in your skeleton app and add or uncomment the component line for the sequence component.
Then you will need to include the zone which implements the zone component (Note: You have not yet created this so it does not exist!).
You will need to create the zone you added above because it does not yet exist. Locate the file zone_default.php in your skeleton app and copy zone_default.php to zone_seqeunce_test.php so you have zone code to start with.
Now edit zone_sequence_test.php and do a search and replace for zone_default. Make sure to replace it with zone_sequence_test. Also changed the extends from zone to zone_sequence.
Your zone should now be accessible at http://www.null.com/sequence_test. If you want to see the built in functions for zones you can navigate to the Zoop folder then open the zone folder and have a look at zone.php then zone_sequence.php. The sequence zone extends regular zones so you should look at them in that order.
Sequences
This is some documentation from an old wiki. We should put this in the new site somewhere.
Why Sequences
Sequencing was created because we had a document creation process that required a user to follow a certain order of pages within one or more zones. There were multiple places that needed to lead to this process. So we made sequences that would order the pages, and then at the end of the process, send the user back to whatever page he had started on. In addition, we sometimes had pages in different orders based on where they came from.
As you might imagine, this led to some very complicated, bug-prone conditional navigation code. So to deal with this, we made an xml-based sequence engine. The idea is that you define how to make an url for a zone, any sequences of pages that a user might travel through for that zone, and then you specify sequences of zones that you will be using. Then inside the code for each zone, you can ignore navigation completely.
As an example, imagine you had something like a forum. You have a "register" process that takes a few page views to complete(because you require their SSN for some silly reason, and their address, and all kinds of things). You want to send them back to wherever they came from. Without sequences, this could be resolved by just saving the url where they clicked register, and returning to it when the register process is completed. However, in addition, you want to reuse the register pages so that registered users can edit their information. Without sequences, you now have to have some kind of logic that stores whether I'm registering or not, and then some logic at the end of each page that does different navigation.
The XML side
The XML used is better documented at SequenceXmlDoc.
With the sequence component, you can instead specify some xml:
<sequences> <zone name="userInfo"> <param name="userId"/> <url> <link name="userInfo"/> </url> <pagesequence name="register"> <step name="basicInfo"/> <step name="extendedInfo"/> <step name="loginInfo"/> </pagesequence> <pagesequence name="edit"> <step name="viewInfo"/> <action name="basic" page="basicInfo"/> <action name="extended" page="extendedInfo"/> <action name="login" page="loginInfo"/> </step> <freepage name="basicInfo"> <action name="back" page="viewInfo"/> </freepage> <freepage name="extendedInfo"/> <action name="back" page="viewInfo"/> </freepage> <freepage name="loginInfo"/> <action name="back" page="viewInfo"/> </freepage> </pagesequence> </zone> <zonesequence name="register"> <param name="userId" value="new"/> <step zone="userInfo" pagesequence="register"/> </zonesequence> <zonesequence name="editUserInfo"> <param name="userId"/> <step zone="userInfo" pagesequence="edit"/> </zonesequence> </sequences>The PHP side
When you want to jump into a sequence, you just create a ZoneSequence object, set the parameters for it, and then getUrl from the object, and it's all taken care of for you.
For the example above, you have some code to enter the sequence like:
$seq = &new ZoneSequence('register'); redirect($seq->getUrl());or
$seq = &new ZoneSequence('editUserInfo'); $seq->setParam('userId', $userId); redirect($seq->getUrl());Now, in your post functions, you don't have any navigation code at all.
Performance
To address concerns about performance, you can rest assured that when you are not using sequences, it doesn't decrease performance at all. When you are, I can only say that the code is all really fast. No complex algorithms in it, and I have not found any human perceptible decreases in performance. It's in use on a heavy production site, without a significant increase in load.
Code Efficiency
As far as using 3 lines of code... If you can use 3 lines of code, I would suggest that you do that. Sequences is really only meant to help in more complex situations. If you think that sequences is too complex for your usage, it probably is. And I will also admit that there is some redundancy in simple situations in the xml. If I get time, I might make it more friendly to simple situations.