Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] CKJModel get instance not working from the plugin

CKJModel get instance not working from the plugin 07 Sep 2014 05:21 #12613

  • vivek
  • vivek's Avatar
  • Offline
  • Premium Member
  • Posts: 123
  • Thank you received: 2
  • Karma: 2
Hi,
I had followed the below article to access a model from the plugin.

www.j-cook.pro/index.php/m/module

It gives non object error on this line.

@include_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_cskpro'.DS.'helpers'.DS.'loader.php');
$model = CkJModel::getInstance('User', 'CskPro');
$item = $model->getItem();

However, the same code works fine on the component which was generated by cook an year back.Did something change recently?

Regards
Vivek
The administrator has disabled public write access.

CKJModel get instance not working from the plugin 09 Sep 2014 16:22 #12615

  • vivek
  • vivek's Avatar
  • Offline
  • Premium Member
  • Posts: 123
  • Thank you received: 2
  • Karma: 2
Any replies ?? Got stuck with this for few days now..

Regards
Vivek
The administrator has disabled public write access.

CKJModel get instance not working from the plugin 09 Sep 2014 16:23 #12616

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Sorry for late answer.
I am gonna check this soon.

Did you tried on fresh install ?
Coding is now a piece of cake
The administrator has disabled public write access.

CKJModel get instance not working from the plugin 09 Sep 2014 16:40 #12617

  • vivek
  • vivek's Avatar
  • Offline
  • Premium Member
  • Posts: 123
  • Thank you received: 2
  • Karma: 2
Solved it by myself..

Here are the lines I had added to the loader.php

// Set the models directory
if ($app->isSite())
CkJController::addModelPath(JPATH_SITE_CHOLALMS .DS.'models');
else
CkJController::addModelPath(JPATH_ADMIN_CHOLALMS .DS.'models');

// Set the table directory
JTable::addIncludePath(JPATH_ADMIN_CHOLALMS . DS . 'tables');
The administrator has disabled public write access.
The following user(s) said Thank You: admin

CKJModel get instance not working from the plugin 10 Sep 2014 12:56 #12618

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
It seems to be a random problem from the JLoader.

To be sure the models are loaded correctly, I have place your code in the end of the loader file, so now it can work. In fact it is the right place.

K++
Coding is now a piece of cake
Last Edit: 10 Sep 2014 12:57 by admin.
The administrator has disabled public write access.
Time to create page: 0.063 seconds

Get Started