frontend controllers

15
Frontend Controllers

Upload: rodnaph

Post on 26-Jun-2015

158 views

Category:

Business


2 download

TRANSCRIPT

Page 1: Frontend Controllers

Frontend Controllers

Page 2: Frontend Controllers

The problems...

Blocks, ContentTypes Not good for UGC Amaxus magicness RequestMediator refactoring Overcomplicating simple things No architecture for tying it all together

Page 3: Frontend Controllers

Amaxus 4 Controllers

Used in backend for everything Basic frontend controllers, but didn't tie in with

the normal page generation

Page 4: Frontend Controllers

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...

Page 5: Frontend Controllers

Simple Controller

class ContentController extends TemplateController {

public function doIndex() {

$oSite = $this->getCurrentSite();

$oUser = $this->getCurrentUser();

$this->respondTo(array(

'html' => array( 'render' => 'index' )

));

}

}

Page 6: Frontend Controllers

Responding...

$this->respondTo(array(

'html' => array( 'render' => 'index' ),

'json' => $this,

'rss' => $oRssFeed,

'text' => 'A plain text response'

));

Page 7: Frontend Controllers

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>

Page 8: Frontend Controllers

Example 1 - Categories

Category controller...

Page 9: Frontend Controllers

Example 2 - Content

Content controller...

Page 10: Frontend Controllers

Templates

Define templates for your controller Templates areas.... @TODO PHP Templating... @TODO Blocks... specify a category in settings!

Page 11: Frontend Controllers

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

Page 12: Frontend Controllers

Route examples...

group/:num/:word = group( id, action )

group/:num/discussions/:num = group:discussions( id, discussionId )

user/login = template:showTemplate( moduleId:Login )

Page 13: Frontend Controllers

Enabling Routing

routing.enabled = 1

routing.specFile = /path/to/routes.spec

Page 14: Frontend Controllers

Things not to do...

• getCommonRequest()

• getSetting()

• getInstance()

• RequestMediator

• etc...

Page 15: Frontend Controllers

The End

“Thank you for your attention, Bye...”