MEG Venture Posted May 11, 2012 Share Posted May 11, 2012 (edited) Hi I am trying to build a form including address information and want to pull out the company, city, phone like information from the database if available and if the customer logged in. I set up the tpl file to manage whether the customer logged in kind controls. In my php file, I used the below code that I inspired from the addresscontroller.php and put in the function to display the tpl file and form: $id_address = (int)Tools::getValue('id_address', 0); if ($id_address) { $this->_address = new Address((int)$id_address); self::$smarty->assign(array('address' => $this->_address, 'id_address' => (int)$id_address)); } I am sending the id_address value to the form page when the user clicsk a button but getting the below error: Fatal error: Access to undeclared static property: quote::$smarty in /home..... Do you know what am I doing wrong? Is there a way to pull those information out to be able to use in a form hat you can suggest? Any help would be appreciated. Regards. Edited May 11, 2012 by Caglar (see edit history) Link to comment Share on other sites More sharing options...
jeevanoss Posted May 11, 2012 Share Posted May 11, 2012 Hi, Are you define $_address; In addresscontroller.php, it is protected $_address; Regards, Link to comment Share on other sites More sharing options...
MEG Venture Posted May 11, 2012 Author Share Posted May 11, 2012 (edited) Yes, I did that, but didn't work. Actually when I define it as protected, in this case it gives me the below error: Parse error: syntax error, unexpected T_PROTECTED If I define as public, it gives me the same Fatal error: Access to undeclared static property error. Edited May 11, 2012 by Caglar (see edit history) Link to comment Share on other sites More sharing options...
MEG Venture Posted May 11, 2012 Author Share Posted May 11, 2012 (edited) OK. I have another question in my mind. I build a new controller, has only a preprocess function in it, and say that its name is addresscontroller1.php How can I call that controler without extending frontcontroller? If it extends front controller using below code, it loads whole header, footer, content once more. ControllerFactory::getController('AddressController1')->run(); UPDATE: Done. Instead of calling run function, I wrote the code I used in the preProcess function I newly built in the addresscontroller1 and it worked when I only call the preProcess function like below: ControllerFactory::getController('AddressController1')->preProcess(); Thanks for all help. Caglar Edited May 11, 2012 by Caglar (see edit history) Link to comment Share on other sites More sharing options...
topit Posted May 11, 2012 Share Posted May 11, 2012 you can write a new method in address1controller.php like this: public function runmain() { $this->init(); $this->preProcess(); $this->process(); $this->displayContent(); } and in address1.php,you can call like this: ControllerFactory::getController('Address1Controller')->runmain(); it will don't show header and footer Link to comment Share on other sites More sharing options...
MEG Venture Posted May 11, 2012 Author Share Posted May 11, 2012 Thank you topit. Is there a way to put the controller file not into the controllers folder, but in my module's folder and then call it from the module's function? When I use below expression, I can't define the path. ControllerFactory::getController('Address1Controller')-> Link to comment Share on other sites More sharing options...
topit Posted May 11, 2012 Share Posted May 11, 2012 First question please show the wrong line number , Under normal circumstances self::$smarty written in this way there are no errors Link to comment Share on other sites More sharing options...
topit Posted May 11, 2012 Share Posted May 11, 2012 if you want to put the controller file not into the controllers folder ,you can put it in the path override/controllers. Link to comment Share on other sites More sharing options...
MEG Venture Posted May 11, 2012 Author Share Posted May 11, 2012 How will I call it then? The same way? ControllerFactory::getController('Address1Controller')->runmain(); Link to comment Share on other sites More sharing options...
topit Posted May 12, 2012 Share Posted May 12, 2012 you can create a new file address1.php in the prestashop root dir then call it in address1.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now