Yii Framework Forum: Load a module's model from the main app controller - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Load a module's model from the main app controller Load a module's model from the main app controller Rate Topic: -----

#1 User is offline   Yung A 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 18-May 15

Posted 10 June 2015 - 03:36 AM

I would like to load/use a model(Importedbooks) which is in module(booksImported) from main app controller(SiteController),

main.php
       'import'=>array(
    'application.models.*',
    'application.components.*',
            'application.modules.booksCategory.models.*', 
            'application.modules.booksImported.models.*' 
         ),
    'modules'=>array('booksImported')
 


In my SiteController function i tried this..which only gives me the Module name.
 Yii::app()->getModule('Importedbooks')



I also tried
       Yii::setPathOfAlias('booksImported','../modules/booksImported/models');

        Yii::import('booksImported.models.Importedbooks',true);  // this will include the class DesiredModel immediately

        $model = Yii::createComponent('Importedbooks');

        print_r($model);

which gives an error
Alias "booksImported.models.Importedbooks" is invalid. Make sure it points to an existing PHP file and the file is readable.


I am really battling with this. Is what i am tying to do possible?, if it is please help.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users