Skip to content

A question about data sent to the view from the controllers #891

@mdk1980

Description

@mdk1980

In view.php (application/core/view.php) there is a foreach loop for data (an array) to be sent to the view when necessary. I can't find a reason for this code nor do I see where in view.php this information is used in any of its internal methods.

The code in question: class: view.php method: render( )

public function render($filename, $data = null)
{
if ($data) {
foreach ($data as $key => $value) {
$this->{$key} = $value;
}
}

This foreach loop information is not used apparently in the subsequent code in view.php that displays information to the user.

require Config::get('PATH_VIEW') . '_templates/header.php';
require Config::get('PATH_VIEW') . $filename . '.php';
require Config::get('PATH_VIEW') . '_templates/footer.php';

heres an example.
In the LoginController (application/controller/) you have a method: index() that feeds information to the view.php

in the index() method in LoginController.php (path=application/controller/LoginController.php)

public function index()
{
    // if user is logged in redirect to main-page, if not show the login/index() method
    if (LoginModel :: isUserLoggedIn()) {
        Redirect::home();
    } else {
        $data = array('redirect' => Request::get('redirect') ? Request::get('redirect') : NULL);  ->  THIS LINE HERE
        $this->View->render('login/index', $data);
    }
}

The 'else' part containing $data sends an array to the render method of view.php that appears to do nothing. Im sure I'm missing something simple here. Any help would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions