frontend controllers
TRANSCRIPT
Frontend Controllers
The problems...
Blocks, ContentTypes Not good for UGC Amaxus magicness RequestMediator refactoring Overcomplicating simple things No architecture for tying it all together
Amaxus 4 Controllers
Used in backend for everything Basic frontend controllers, but didn't tie in with
the normal page generation
XSL Rendering
You can now use XSL (and hopefully PHP) templating for controllers
Ties in with the rest of the Amaxus so blocks can be used, CSS, Javascript, etc...
Simple Controller
class ContentController extends TemplateController {
public function doIndex() {
$oSite = $this->getCurrentSite();
$oUser = $this->getCurrentUser();
$this->respondTo(array(
'html' => array( 'render' => 'index' )
));
}
}
Responding...
$this->respondTo(array(
'html' => array( 'render' => 'index' ),
'json' => $this,
'rss' => $oRssFeed,
'text' => 'A plain text response'
));
XSL Templates
Store in controller directory eg. MyController.all.all.xsl Name templates after actions you want to
render. So for array( 'render' => 'index' )...
<xsl:template name=”MyController_index”>
</xsl:tempate>
Example 1 - Categories
Category controller...
Example 2 - Content
Content controller...
Templates
Define templates for your controller Templates areas.... @TODO PHP Templating... @TODO Blocks... specify a category in settings!
Routing
From:
_server.php?controller=group&action=edit&id=123
_server.php?controller=group&action=discussions\
&id=123&discussionId=456
To:
/group/123/edit
/group/123/discussions/456
Route examples...
group/:num/:word = group( id, action )
group/:num/discussions/:num = group:discussions( id, discussionId )
user/login = template:showTemplate( moduleId:Login )
Enabling Routing
routing.enabled = 1
routing.specFile = /path/to/routes.spec
Things not to do...
• getCommonRequest()
• getSetting()
• getInstance()
• RequestMediator
• etc...
The End
“Thank you for your attention, Bye...”