I want to put the “blog yii demo” as a module into my website but I’ve just come across a PHP warning: “include(Post.php): failed to open stream: No such file or directory”. This is the code of the controller:
Hi since you created this as a module, make sure that in modules/modulename/model/ there is a Post.php model file. But based on your statement you already put Post.php in models dir.
Here is another thing to check.
class ModuleNameModule extends CWebModule
{
public $defaultController ="Post"; //or the name of your controller
public function init()
{
// this method is called when the module is being created
// you may place code here to customize the module or the application
// import the module-level models and components
$this->setImport(array(
'branch.models.*', // make sure that you have this
'branch.components.*',
));
}
It worked! Thanks a lot. However, another problem has arisen: I would like to use the layout of the main application, not the layout of the module. How can I solve this?
class ModuleController extends Controller {
/**
* @var string the default layout for the views. Defaults to '//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public $layout = '//layouts/column2';