AllAdvertisements.php there is on the /protected/components :
<?php
/**
* AllAdvertisements is a Yii widget used to display a list of All Advertisements
*/
class AllAdvertisements extends CWidget
{
private $_Advertisements;
public $userId = null;
public function init()
{
$this->_Advertisements = Advertisement::model()->findAllAdvertisements($this->userId);
}
public function getAllAdvertisements()
{
return $this->_Advertisements;
}
public function run()
{
// this method is called by CController::endWidget()
$this->render('AllAdvertisementsview');
}
}
And, AllAdvertisementsview.php on the /protected/components/views :
require() [<a href='function.require'>function.require</a>]: Filename cannot be empty
?
Seems to me, provided code is ok and should work.
P.S. By the way, I recomment not to use such a paths in ‘itemView’=>’/protected/views/advertisement/_view’ because if application would be placed in some other folder, path would be wrong. Use something like ‘//advertisment/_view’ instead.
Add you Widget class to components/ folder for example. This new Widget class should extend base CWidget class - and in your realisation of Widget class you could override getViewPath, And all your widget should derive from thsi new Widget class.
Lastday is absolutely correct in that CWidget::render() method by default tries to find file within views/ folder on the same level where derived widget class located.
In our scenario,we can solve it by calling the owner controller.
In CWidget.php declarion of method is following - public function getViewPath($checkTheme=false). So add parameter $checkTheme=false to your method in children class.