0
votes

I would like to say that i am quite new to prestashop.

I have added FrontController.php to override/classes/controller. The file contains the following code

class FrontControllerCore extends Controller
{

public function thefunct()
{
    return 'AA';
}

}

Now in the header.tpl i try to call the function by using {FrontController::thefunct()}.

When I put the public function in classes/controller it works, but when I put it in the override folder it doesn't.

How do I display the function in my header.tpl? And how does the override folder work then?

1

1 Answers

1
votes

(I assume you use ps 1.5)

If you are overriding FrontController you need to initiate your class like so

class FrontController extends FrontControllerCore

and delete cache/class_index.php file, (I mean, delete it everytime you override new controller or class)

Teach yourself how to override in ps. through excellent docs.

EDIT:

class FrontController extends FrontControllerCore {

    //here you should create and assign variables which you want to use in templates
    public function initContent()
    {
        parent::initContent();

        //in such a way you assign variables into smarty template
        $this->context->smarty->assign(
            array(
                'acme_variable' => $this->acme()
            )
        );
    }

    protected function acme()
    {
        return "Wile E. Coyote and The Road Runner";
    }
}


//header.tpl

<div>{$acme_variable}</div>