Jump to content

[Solved] Fatal error: Access to undeclared static property


MEG Venture

Recommended Posts

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 by Caglar (see edit history)
Link to comment
Share on other sites

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 by Caglar (see edit history)
Link to comment
Share on other sites

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 by Caglar (see edit history)
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...