jaysondotph Posted May 12, 2014 Share Posted May 12, 2014 Hi i have php code that i need to load in header.tpl, my code is an native way of coding style. now i put it under controllers and my question is how do i call my php code into my tpl same as like include? shop/controllers/front ->mycode.php shop/themes/default-bootstrap/->header.tpl Link to comment Share on other sites More sharing options...
NemoPS Posted May 12, 2014 Share Posted May 12, 2014 I am not sure I understood your needs... What do you want the script to do? As you placed it in the controllers folder, do you want it to create a new page? Link to comment Share on other sites More sharing options...
jaysondotph Posted May 13, 2014 Author Share Posted May 13, 2014 Hi.. i want to add visitors online at part of header. and to make it work i need to link or include the php file into header.tpl but i have no idea how it to load. Link to comment Share on other sites More sharing options...
jaysondotph Posted May 13, 2014 Author Share Posted May 13, 2014 (edited) i have php file function for visitors that i need to link it into tpl, and i place the php file into shop/controllers/front ->visitors.php and i dont know if it is correct. and now i have no idea how to get the said function from php that i need to link in tpl file. shop/themes/default-bootstrap/->header.tpl please any idea for it, and i really2x need you each help.. Edited May 13, 2014 by jaysondotph (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 13, 2014 Share Posted May 13, 2014 you can use your code as a static function in FrontController you can create there function: public static function myFunction(){ // your php code return "value"; } then in header tpl you can use: {FrontController::myFunction()} you will see there result of your myFunction (return value) Link to comment Share on other sites More sharing options...
jaysondotph Posted May 14, 2014 Author Share Posted May 14, 2014 Thanks vekia.. and its work great. Thanks Link to comment Share on other sites More sharing options...
jaysondotph Posted May 14, 2014 Author Share Posted May 14, 2014 Hi vekia, i notice that there are two redundant output instead one. i wright my code something like this php controller: public static function ocs_visitors() { return include 'visitors.php'; } header.tpl {IndexControllerCore::ocs_visitors()} and what is the possible solution on this or what is the cause of this kind of error? Link to comment Share on other sites More sharing options...
jaysondotph Posted May 14, 2014 Author Share Posted May 14, 2014 Hi Problem solve Link to comment Share on other sites More sharing options...
Recommended Posts