Post by johnnyart » Tue Mar 02, 2010 5:29 pm

Hi there,
Maybe I'm approaching this the wrong way, but I'm writting a custom model to do some ajax validation of the user
login and password and can't seem to access the ControllerAccountLogin class rrom my new model.
I've used another frameworks before and for example in codeigniter I could create an instance of the core object doing something like $CI =& get_instance();. That way the newly created variable would have access to all of the core classes and functions.

Meaning I could do something like $CI->ControllerID->functionID

I'm just struggling to use the current user validation from within my custom model.
Is something similar available here?

User avatar
Newbie

Posts

Joined
Tue Mar 02, 2010 5:13 pm

Post by Qphoria » Tue Mar 02, 2010 8:51 pm

Models don't call controllers. Controllers load models and call to them.
When in the controller, you can use $this->class->function from controllers to load any library class or and loaded model function.

Registered Library Examples:
$this->currency->format()
$this->cart->getSubTotal()
$this->customer->getCustomerGroupId()
etc

Model Examples:
$this->load->model('catalog/product');
$this->model_catalog_product->getProducts();

$this->load->model('account/address');
$this->model_account_address->getAddress();

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Xsecrets » Tue Mar 02, 2010 10:00 pm

so in short you need to write a controller too not just a model.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Qphoria » Tue Mar 02, 2010 10:46 pm

unless it is a model-controller like a shipping or order total module, then those are special case

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by deeve » Fri May 28, 2010 5:17 pm

Hi Q,

I just attempted to clone the Free Shipping mod so I could offer an 'Expedited Free Shipping' version as well. I followed your instructions on how to clone a mod but am getting an error saying:

Fatal Error: 'Class Controllershippingsxpedite' not found in 'my path../system/engine/home.php'.

I basically replaced all instances of 'free' with 'expedite' in all 5 'free' files but feels as though I need to register a new class or change the way it uses the Free Shipping Class?

Thanks in advance for any advice.

Active Member

Posts

Joined
Tue Oct 20, 2009 4:31 pm

Post by Qphoria » Fri May 28, 2010 9:38 pm

looks like a typo:
Controllershippingsxpedite

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by deeve » Fri May 28, 2010 9:51 pm

Hi Q,

sorry, that was just my typo when I posted the error.

The actual error in the code was that I hadn't repeated the case sensitive word change in admin/controller shipping/expedite.php of: ControllerShippingExpedite

& in catalog/model/shippipng/expedite.php of: ModelShippingExpedite

That done it all seems to work swimmingly ;)

Many thanks for another great tutorial!

Active Member

Posts

Joined
Tue Oct 20, 2009 4:31 pm
Who is online

Users browsing this forum: No registered users and 10 guests