Is this right way to do:
I create a model, controller, view for localhost/users and do the same for localhost/hello-world. Now that I have two views (template designs) for controllers how can I use them in third controller like localhost/home (DashboardController in the code)?
namespace app\controllers;
use app\models\Users;
use app\controllers\HelloWorldController;
class DashboardController extends \lithium\action\Controller {
public function index() {
$users = Users::find('first');
$hello = HelloWorldController::to_string();
return compact('users', 'hello');
}
}
Do I have to style again $users and $hello in DashboardController view and in other new controllers where I want to use multiple models, or I can use their own views which I made at the beginning? This question is really bothering me, becouse I'm new in MVC and frameworks.
If you only require sections you could use Lithium elements.
echo $this->view()->render(array('element' => 'name of element'), array('datavar' => $passingDataIn))
If you need to just render the same view again you could essentially tell the Controller method to use the view:
return $this->render(array('template' => 'dashboard/index.html.php')));