Now, we should modify BaseController.php
from the Frontend
module to extend the core module and to assign categories globally to our views upon each request. Open modules/Frontend/Controllers/BaseController.php
, clear its contents, and append this code:
<?php namespace App\Frontend\Controllers; class BaseController extends \App\Core\Controllers\BaseController { public function afterExecuteRoute() { $this->view->categories = $this->apiGet('categories'); } }
We don't actually have a home page (but we can add one anytime we want), so we are going to forward the request to ArticlesController
. Open modules/Frontend/Controllers/IndexController.php
, remove indexAction()
, and append the following code:
public function indexAction() { return $this->dispatcher->forward([ 'controller' => 'article', 'action' => 'list' ]); }
The last step is to create the listAction()
method and the view for the articles....