[TYPO3-ect] Controller Configuration
steve ryan
stever at syntithenai.com
Thu Mar 23 12:41:13 CET 2006
Has anyone thought about a generic controller driven by TS
configuration? Great for extending the kickstarter to include "Add New
Process".
Example from trade and fewizards extensions below.
Don't need dynamic instantiation for the controller. Array munching is
natural and fast.
The downside is flexibility and comprehensibility. A good model and
occasional evals help a lot here.
I also like that you are pushed to be very tight about the interface
between HTML forms and the controller.
Code based controllers are heaps more flexible but less tightly defined.
I've always been a big fan of DRY. Building user interfaces and admin
controllers from meta data, done. Defining process models is an
interesting and powerful way to get more value out of our codebase for
non programmers too.
Steve Ryan
---------FEWIZARDS CONTROLLER CONFIGURATION---
This is based on a working demo put together with Ingmaar, Greg, Matt
and Roger. The demo was very thin on user interface rendering libraries
but the basics for text inputs to search/edit works.
Extension download http://syntithenai.com/fewizards.zip. Carsearch is
the demo, fewizards the libraries.
defaultActivity = searchForm
activities {
searchForm {
preProcessing (
if($this->piVars['searchForm']) {
$this->prepareDS('carSearchForm','formEval');
list($errors,$checkedValues) =
tx_fewizards_form::evaluate($this->currentDS,$this->piVars['searchForm']);
$this->session['searchForm'] = $checkedValues;
unset($this->piVars['searchForm']);
}
)
nextActivity {
10.value=reset
10.label=Reset Search Parameters
20.value=list
20.label=Do Search!!
20.condition=sizeof($errors)==0
}
action (
$this->prepareDS('carSearchForm','form',$this->session['searchForm']);
)
output {
10 < lib.tx_fewizards.output.form.autoForm
30 < lib.tx_fewizards.output.buttons
#20 < lib.tx_fewizards.output.general.obInclude
#20.templateFile = EXT:carsearch/templates/searchform.inc
}
}
list {
preProcessing (
)
nextActivity < plugin.tx_carsearch_pi1.activities.searchForm.nextActivity
nextActivity.30 {
value=view
label=View
}
nextActivity.40 {
value=print
label=Print
}
nextActivity.5 {
value=searchForm
label=Change search words
}
action (
if($cmd === 'list') $session['SEARCHFORM']=$this->piVars['searchForm'];
$this->prepareDS('carSearchForm','form',$session['SEARCHFORM']);
// what about pulling this from the session
$rows =
tx_fewizards_db::dbSearch($queries['customSearch'],$session['SEARCHFORM']);
$this->prepareDS('shortList','list',$rows);
)
output {
10 < lib.tx_fewizards.output.list.autoList
#20 < lib.tx_fewizards.output.general.obInclude
#20.templateFile = EXT:carsearch/templates/list.inc
30 < lib.tx_fewizards.output.buttons
}
}
view {
preProcessing (
)
nextActivity.10 {
value=list
label=Back
condition=$cmd === 'back'
}
action (
$this->prepareDS($ds['carView'],$session['DATA']);
)
output.template.file=EXT:carsearch/templates/view.inc
}
reset {
preProcessing (
unset($this->session['searchForm']);
)
nextActivity {
10.value=searchForm
}
}
errorMsg {
# alternative template configuration from static PHP file for
customisation
output.template.file=EXT:carsearch/templates/errtemplate.inc
}
noResults {
output.template.file=EXT:carsearch/templates/noresults.inc
}
}
}
----- SIMPLER TRADE CHECKOUT CONFIGURATION
This process meta data allows the trade extension to select what stage
in a checkout process should be rendered.
checkout {
list {
condition=$testResult=true;
next=basket
label=Select Products
label.stdWrap.wrap=
}
basket {
condition=if (sizeof($this->basket)>0 && $this->shipping['method']>0
&& $this->payment['method']>0 &&
(($this->piVars['submit_payment_method']==1 &&
$this->piVars['submit_shipping_method']==1)||$this->user['basket_approved']==1)
) $testResult=true;
next=user_shipping_details
templateSubpart=BASKET
label=Payment/Shipping Details
label.stdWrap.wrap=
}
user_shipping_details {
condition=if ($this->user['valid']==1 &&
$this->user['valid_shipping_details']==1&&$this->user['basket_approved']==1)
$testResult=true;
next=confirm
templateSubpart=USER_SHIPPING_DETAILS
label=Customer Details
label.stdWrap.wrap=
}
confirm {
#condition=if ($this->order['status']==1) $testResult=true;
condition=if
($this->piVars['finalise_checkout']==1&&$this->user['valid_shipping_details']==1&&$this->user['valid']==1&&$this->user['basket_approved']==1)
$testResult=true;
next=thanks
templateSubpart=CONFIRM
label=Confirmation
label.stdWrap.wrap=
}
thanks {
condition=$testResult=false;
next=NOT USED
templateSubpart=THANKS
label=Order Complete
label.stdWrap.wrap=
}
More information about the TYPO3-team-extension-coordination
mailing list