Welcome to Discussion Forum, where you can ask questions and receive answers from other members of the community.

Please help: calling controller method from href tag in tpl?

1 like 0 dislike
hi ,
 
I tried calling the front controller method from a tpl anchor tag, is it possible to call front controller ?  
 
I need to call front controller method from href call. Please help 
 
I need the Solution for prestashop v1.7 
asked Jun 9, 2017 in Prestashop by harsh (8,710 points)

1 Answer

0 like 0 dislike
Just include the front controller class file into the file which is rendering TPL file as follows:

include_once(_PS_MODULE_DIR.'yourmodule/controllers/front/yourcontroller.php);

class YourSecondFrontControllerClass extends YourControllerClass

{

---- CODE HERE ------

}

And then you can call the function of parent controller using the following syntax.

{YourParentController::testFunction()}
 
---------------------------------------------------------------------------------------------------------

 
Other option is that you can make a duplicate function in the controller rendering the TPL tile and then can directly call the function as follows:

{YourMainFrontController::testFunction()}

Note: The function that you want to call should be a public static function.

I hope this helps. Please feel free to ask in case of any query or issue.
answered Jun 9, 2017 by raghu_velsof (590 points)

Related questions

0 like 0 dislike
1 answer 145 views
145 views asked Feb 17, 2017 in Opencart by harsh (8,710 points)
0 like 0 dislike
0 answers 36 views
36 views asked Jun 1, 2017 in Prestashop by harsh (8,710 points)
0 like 0 dislike
1 answer 26 views
26 views asked Mar 7, 2017 in Prestashop by harsh (8,710 points)
0 like 0 dislike
1 answer 2,418 views
...