Есть сайт на YII,он работает на версий PHP 5.3 (Denwer) и всё отлично, если поставить тот-же сайт на PHP 5.6(XAMPP) то при входе появляется такая ошибка: PHP: beginContent('//layouts/main'); echo $content; $this->endContent(); ?> Я пытался как-нибудь исправить это, но ничего не получилось. Не знаю что уже делать :/ Думаю вы поможете...
При входе лишь это пишет: PHP: beginContent('//layouts/main'); echo $content; $this->endContent(); ?> И ничего больше, хотя на Denwer-e всё работает нормально..
Приучайте себя писать <?php везде, а не короткое <? Отключенный short_open_tag встречается часто и ставится по дефолту теперь в конфигах. <?= при этом можно использовать без проблем всегда
до какой-то там версии оно считалось коротким тэгом и попадало под настройки. А потом его сделали коротким эхо и оно перестало попадать под настройки тэга.
Да, но теперь сайт криво прогружаеться: Вот что пишет: PHP: [B]Notice[/B]: Use of undefined constant id - assumed 'id' in [B]C:\xampp\htdocs\protected\models\Monitors.php[/B] on line [B]59[/B] [B]Notice[/B]: Use of undefined constant mon_name - assumed 'mon_name' in [B]C:\xampp\htdocs\protected\models\Monitors.php[/B] on line [B]59[/B] [B]Notice[/B]: Use of undefined constant id - assumed 'id' in [B]C:\xampp\htdocs\framework\zii\widgets\FrapsyNavbar.php[/B] on line [B]22[/B] [B]Notice[/B]: Use of undefined constant mon_name - assumed 'mon_name' in [B]C:\xampp\htdocs\framework\zii\widgets\FrapsyNavbar.php[/B] on line [B]23[/B] [LIST] [B]Notice[/B]: Use of undefined constant items - assumed 'items' in [B]C:\xampp\htdocs\framework\zii\widgets\FrapsyNavbar.php[/B] on line [B]61[/B] [B]Notice[/B]: Use of undefined constant url - assumed 'url' in [B]C:\xampp\htdocs\framework\zii\widgets\FrapsyNavbar.php[/B] on line [B]79[/B] [B]Notice[/B]: Use of undefined constant url - assumed 'url' in [B]C:\xampp\htdocs\framework\zii\widgets\FrapsyNavbar.php[/B] on line [B]80[/B] [B]Notice[/B]: Use of undefined constant label - assumed 'label' in [B]C:\xampp\htdocs\framework\zii\widgets\FrapsyNavbar.php[/B] on line [B]80[/B] [*][URL='http://localhost/']Главная[/URL] [B]Notice[/B]: Use of undefined constant items - assumed 'items' in[B]C:\xampp\htdocs\framework\zii\widgets\FrapsyNavbar.php[/B] on line [B]61[/B] [B]Notice[/B]: Use of undefined constant label - assumed 'label' in [B]C:\xampp\htdocs\framework\zii\widgets\FrapsyNavbar.php[/B] on line [B]64[/B] [*][URL='http://localhost/#']Составы [/URL] [B]Notice[/B]: Use of undefined constant items - assumed 'items' in[B]C:\xampp\htdocs\framework\zii\widgets\FrapsyNavbar.php[/B] on line [B]61[/B] [B]Notice[/B]: Use of undefined constant url - assumed 'url' in [B]C:\xampp\htdocs\framework\zii\widgets\FrapsyNavbar.php[/B] on line [B]79[/B] [B]Notice[/B]: Use of undefined constant url - assumed 'url' in [B]C:\xampp\htdocs\framework\zii\widgets\FrapsyNavbar.php[/B] on line [B]80[/B] [B]Notice[/B]: Use of undefined constant label - assumed 'label' in [B]C:\xampp\htdocs\framework\zii\widgets\FrapsyNavbar.php[/B] on line [B]80[/B] [*][URL='http://localhost/site/login']Личный кабинет[/URL][B][SIZE=4][php][/SIZE][/B] [/LIST]
@Johhny оно и раньше такое писало, просто был отключен вывод ошибок и предупреждений. Рискну предположить, что там в каждой из этих строк идёт обращение к ключу массива. Решение: взять название ключа в кавычки чтоб из константы образовалась строка.
Тоесть, у нас есть строка: PHP: $items[$val['id']] = array('id'=>$val['id'],'label'=>$val['label'],'url'=>$val['url'],'items'=>$subitems[$val['id']]); И мне нужно сделать так? PHP: "$items"[$val['id']] = array('id'=>$val['id'],'label'=>$val['label'],'url'=>$val['url'],'items'=>$subitems[$val['id']]);
Лол. Этого не может быть. Смотри: $var[id] - вот тут я написал ту ситуацию которая у тебя. Айди написано без кавычек. Пхп-машина будет искать такую константу и пытаться подставить её значение. Если не найдет - создаст константу значением которой будет имя константы и соответственно эту строку уже вернет как имя ключа. Но на это будет кинут нотис о неопределенной константе. Что еще тут может случиться? Неопределенный индекс массива. Да, константу развернуло в строку или получилось её значение но вот беда - в массиве нет такого индекса. Результат: нотис о потерянном ключе массива. И наконец: неопределенная переменная вар! Да, константу мы развернули, но при попытке обратиться к переменной вар в контексте массива вдруг выясняется что нет у нас такой переменной. Результат: нотис о неопределенной переменной. Итак. У нас есть три различных нотиса на все случаи жизни что называется. Теперь прочитай свои нотисы и подумай к какому случаю они относятся.
framework\zii\widgets\FrapsyNavbar.php - это что? Ты что, свои классы запихнул в структуру фреймворка? Так нельзя делать. Свой код держи у себя, фрейморк - as is он развернулся из дистрибутива.
Вот что в нём находиться: PHP: <?php class FrapsyNavbar extends CWidget { public function init() { // } public function run() { $items = array(); $items = Menu::getMenuItems(); $arr = Tops::getTops(); if(!empty($arr)) { foreach($arr as $val) { $tops[] = array('label'=>$val[top_name],'url'=>'/tops/view/'.$val[id]); } $items[] = array('label'=>'Рейтинги','url'=>'#','items'=>$tops); } $arr = Monitors::getMonitors(); if(!empty($arr)) { foreach($arr as $val) { if($val[id] == 1) $monitors[] = array('label'=>$val[mon_name],'url'=>'/monitor/fractions'); else $monitors[] = array('label'=>$val[mon_name],'url'=>'/monitor/view/'.$val[id]); } $items[] = array('label'=>'Составы','url'=>'#','items'=>$monitors); } if(!Yii::app()->user->isGuest AND Yii::app()->user->admin >= Yii::app()->params->editor_level) { $items[] = array('label'=>'Админ-панель','url'=>'#','items'=>array( array('label'=>'Параметры сайта','url'=>'/site/config'), array('label'=>'Файлы HTML и CSS','url'=>'/site/design/1'), array('label'=>'Настройка таблицы','url'=>'/site/settings/1'), array('label'=>'Сортировка полей','url'=>'/site/sort/1'), array('label'=>'Настройка названий','url'=>'/site/names'), array('label'=>'Изменение ников','url'=>'/changename/admin'), array('label'=>'Добавить новость','url'=>'/news/create'), array('label'=>'Создать топ-лист','url'=>'/tops/create'), array('label'=>'Создать мониторинг','url'=>'/monitor/create'), array('label'=>'Добавить таблицу','url'=>'/tables/create'), array('label'=>'Редактор меню','url'=>'/site/editmenu'), array('label'=>'Управление рейтингами','url'=>'/tops/admin'), array('label'=>'Управление мониторингами','url'=>'/monitor/admin'), array('label'=>'Управление таблицами','url'=>'/tables/'), )); } if(Yii::app()->user->isGuest) { $items[] = array('label'=>'Личный кабинет','url'=>'/site/login'); } else { $items[] = array('label'=>'Личный кабинет','url'=>'#','items'=>array( array('label'=>'Просмотр','url'=>'/id'.Yii::app()->user->userid), array('label'=>'Настройки','url'=>'/users/change'), array('label'=>'Выйти','url'=>'/site/logout'), )); } $this->renderMenu($items); } protected function renderMenu($items) { echo '<ul class="nav navbar-nav navbar-center">'; foreach($items as $val) { if(isset($val[items])) { echo ' <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">'. $val[label]. ' <i class="caret"></i></a>'; echo '<ul class="dropdown-menu">'; foreach($val[items] as $sub) { if(isset($sub['class'])) { echo '<li class='.$sub["class"].'></li>'; } else { if(!preg_match('/(http|https)/',$sub[url])) echo '<li><a href="'.Yii::app()->baseUrl.$sub[url].'">'.$sub[label].'</a></li>'; else echo '<li><a href="'.$sub[url].'">'.$sub[label].'</a></li>'; } } echo '</ul></li>'; } else { if(!preg_match('/(http|https)/',$val[url])) echo '<li><a href="'.Yii::app()->baseUrl.$val[url].'">'.$val[label].'</a></li>'; else echo '<li><a href="'.$val[url].'">'.$val[label].'</a></li>'; } } echo '</ul>'; } }
Совершенно пофиг что в нем, он не должен быть в папке фреймворка, он должен быть в папке твоего проекта. echo'<li><a href="'.Yii::app()->baseUrl.$val[url].'">'.$val[label].'</a></li>'; Без кавычек, о чем тебе и говорили выше.
Остались лишь 3 ошибки, но я не знаю как их решить: Notice: Undefined variable: subitems in C:\xampp\htdocs\protected\models\Menu.php on line 71 Notice: Use of undefined constant id - assumed 'id' in C:\xampp\htdocs\protected\models\Monitors.php on line 59 Notice: Use of undefined constant mon_name - assumed 'mon_name' in C:\xampp\htdocs\protected\models\Monitors.php on line 59 PHP: $items[$val["id"]] = array("id"=>$val["id"],"label"=>$val["label"],"url"=>$val["url"],"items"=>$subitems[$val["id"]]);//71 PHP: if($val["parent_id" ]) {//59
ну ты сам-то не видишь что в строках нотисов и в строках кода иногда нет ничего общего. что это с 59 строкой? где мон-нейм в ней?
он обязан быть в исходном коде, понимаешь? вот эта херота if($val["parent_id" ]) {//59 должна выглядеть как минимум как if($val["mon_name" ]) {//59 а далее уже содержать в себе ранее обсуждаемые проблемы. но у тебя написано иф+вал+парент-айди а ошибка говорит про мон-нейм - тебя вообще это не коробит ищи мон нейм в 59 строке файла C:\xampp\htdocs\protected\models\Monitors.php. пхп-машина всё что может делает чтоб ты быстро отладил своё приложение.
Ошибка:Notice: Undefined variable: subitems in C:\xampp\htdocs\protected\models\Menu.php on line 71 Напрямую связанно с subitems, она в этой строк: PHP: $items[$val['id']] = array('id'=>$val['id'],'label'=>$val['label'],'url'=>$val['url'],'items'=>$subitems[$val['id']]); Но проблема в том что я уже больше 5 раз прочитал ваши сообщения и так и не понял как тут всё сделать, с остальными вроде справился, надеюсь что всё будет работать... Спойлер: Всё то что нашел Notead++ PHP: Search "subitems" (51 hits in 4 files) C:\xampp\htdocs\js\codemirror\mode\rst\index.html (1 hit) Line 126: * and some subitems C:\xampp\htdocs\protected\controllers\SiteController.php (4 hits) Line 25: $subitems = array(); Line 29: $subitems[$val['parent_id']][] = array('id'=>$val['id'],'label'=>$val['label'],'url'=>$val['url']); Line 31: $subitems[$val['parent_id']][] = array('id'=>$val['id'],'class'=>$val['label']); Line 34: $items[$val['id']] = array('id'=>$val['id'],'label'=>$val['label'],'url'=>$val['url'],'items'=>$subitems[$val['id']]); C:\xampp\htdocs\protected\models\Menu.php (3 hits) Line 63: $subitems[$val['parent_id']][] = array('id'=>$val['id'],'label'=>$val['label'],'url'=>$val['url']); Line 67: $subitems[$val['parent_id']][] = array('id'=>$val['id'],'class'=>$val['label']); Line 71: $items[$val['id']] = array('id'=>$val['id'],'label'=>$val['label'],'url'=>$val['url'],'items'=>$subitems[$val['id']]); C:\xampp\htdocs\protected\runtime\application.log (43 hits) Line 5355: 2016/06/22 16:15:16 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5379: 2016/06/22 16:15:54 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5403: 2016/06/22 16:17:31 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5427: 2016/06/22 16:19:28 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5451: 2016/06/22 16:24:14 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5475: 2016/06/22 16:26:09 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5499: 2016/06/22 16:28:32 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5523: 2016/06/22 16:34:28 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5547: 2016/06/22 16:35:53 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5571: 2016/06/22 16:36:59 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5595: 2016/06/22 16:37:05 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5627: 2016/06/22 16:45:31 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5651: 2016/06/22 16:46:57 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5675: 2016/06/22 16:48:59 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5699: 2016/06/22 16:54:13 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5723: 2016/06/22 16:56:30 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5867: 2016/06/22 17:11:21 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5915: 2016/06/22 17:20:45 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5939: 2016/06/22 17:26:24 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5963: 2016/06/22 17:27:39 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 5987: 2016/06/22 17:37:57 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6011: 2016/06/22 17:38:10 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6035: 2016/06/22 17:39:08 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6059: 2016/06/22 17:39:46 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6083: 2016/06/22 17:41:20 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6107: 2016/06/22 17:41:56 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6131: 2016/06/22 17:43:09 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6155: 2016/06/22 17:43:27 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6179: 2016/06/22 18:15:53 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6203: 2016/06/22 18:31:57 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6227: 2016/06/22 18:32:11 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6251: 2016/06/22 18:32:24 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6275: 2016/06/22 18:32:45 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6299: 2016/06/22 18:33:06 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6323: 2016/06/22 18:33:23 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6347: 2016/06/22 18:33:50 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6371: 2016/06/22 18:34:01 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6395: 2016/06/22 18:34:41 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6419: 2016/06/22 18:35:37 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6443: 2016/06/22 18:35:44 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6467: 2016/06/22 18:38:49 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6501: 2016/06/22 18:45:29 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Line 6525: 2016/06/22 18:47:26 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Спойлер: application.log PHP: 2016/06/22 18:53:02 [error] [php] Undefined variable: subitems (C:\xampp\htdocs\protected\models\Menu.php:71) Stack trace: #0 C:\xampp\htdocs\protected\views\layouts\main2.php(53): LandingController->widget() #1 C:\xampp\htdocs\framework\web\CBaseController.php(126): require() #2 C:\xampp\htdocs\framework\web\CBaseController.php(95): LandingController->renderInternal() #3 C:\xampp\htdocs\framework\web\widgets\CContentDecorator.php(76): LandingController->renderFile() #4 C:\xampp\htdocs\framework\web\widgets\CContentDecorator.php(54): CContentDecorator->decorate() #5 C:\xampp\htdocs\framework\web\widgets\COutputProcessor.php(44): CContentDecorator->processOutput() #6 C:\xampp\htdocs\framework\web\CBaseController.php(206): CContentDecorator->run() #7 C:\xampp\htdocs\framework\web\CBaseController.php(300): LandingController->endWidget() #8 C:\xampp\htdocs\protected\views\layouts\landing.php(7): LandingController->endContent() #9 C:\xampp\htdocs\framework\web\CBaseController.php(126): require() #10 C:\xampp\htdocs\framework\web\CBaseController.php(95): LandingController->renderInternal() #11 C:\xampp\htdocs\framework\web\CController.php(797): LandingController->renderFile() #12 C:\xampp\htdocs\protected\controllers\LandingController.php(9): LandingController->render() #13 C:\xampp\htdocs\framework\web\actions\CInlineAction.php(49): LandingController->actionIndex() #14 C:\xampp\htdocs\framework\web\CController.php(318): CInlineAction->runWithParams() #15 C:\xampp\htdocs\framework\web\CController.php(296): LandingController->runAction() #16 C:\xampp\htdocs\framework\web\CController.php(275): LandingController->runActionWithFilters() #17 C:\xampp\htdocs\framework\web\CWebApplication.php(282): LandingController->run() #18 C:\xampp\htdocs\framework\web\CWebApplication.php(141): CWebApplication->runController() #19 C:\xampp\htdocs\framework\base\CApplication.php(180): CWebApplication->processRequest() #20 C:\xampp\htdocs\index.php(7): CWebApplication->run() REQUEST_URI=/index.php
Спойлер: Menu.php PHP: <?php class Menu extends CActiveRecord { public function getDbConnection() { $connection = new CDbConnection( "mysql:host=".Yii::app()->params->mysql_host.";dbname=".Yii::app()->params->mysql_dbname, Yii::app()->params->mysql_user, Yii::app()->params->mysql_pass ); $connection->charset = 'utf8'; return $connection; } public function tableName() { return 'frapsy_menu'; } public function rules() { return array( array('label,url,parent_id','safe'), ); } public static function getMenu() { $menu = self::model()->findAll(array('order'=>'parent_id DESC, id')); if($menu !== null) return $menu; else return null; } public static function getMenuItems() { $menu = self::model()->findAll(array('order'=>'parent_id DESC, id')); if($menu !== null) { $items = array(); foreach($menu as $val) { if($val["parent_id" ]) { if($val['label'] !== 'divider') $subitems[$val['parent_id']][] = array('id'=>$val['id'],'label'=>$val['label'],'url'=>$val['url']); else $subitems[$val['parent_id']][] = array('id'=>$val['id'],'class'=>$val['label']); } else { $items[$val['id']] = array('id'=>$val['id'],'label'=>$val['label'],'url'=>$val['url'],'items'=>$subitems[$val['id']]); } } return $items; } else return null; } /* public static function deleteMenu($id) { $connect = self::getDbConnection(); $connect->createCommand(); $connect->delete(self::tableName(),'id = :id OR parent_id = :id',array(':id'=>$id)); } */ public static function model($className=__CLASS__) { return parent::model($className); } } ?> --- Добавлено --- Спойлер: CBaseController.php PHP: <?php public function renderFile($viewFile,$data=null,$return=false) { $widgetCount=count($this->_widgetStack); if(($renderer=Yii::app()->getViewRenderer())!==null && $renderer->fileExtension==='.'.CFileHelper::getExtension($viewFile)) $content=$renderer->renderFile($this,$viewFile,$data,$return); else $content=$this->renderInternal($viewFile,$data,$return); if(count($this->_widgetStack)===$widgetCount) return $content; else { $widget=end($this->_widgetStack); throw new CException(Yii::t('yii','{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.', array('{controller}'=>get_class($this), '{view}'=>$viewFile, '{widget}'=>get_class($widget)))); } } public function renderInternal($_viewFile_,$_data_=null,$_return_=false) { // we use special variable names here to avoid conflict when extracting data if(is_array($_data_)) extract($_data_,EXTR_PREFIX_SAME,'data'); else $data=$_data_; if($_return_) { ob_start(); ob_implicit_flush(false); require($_viewFile_); return ob_get_clean(); } else require($_viewFile_); } public function createWidget($className,$properties=array()) { $widget=Yii::app()->getWidgetFactory()->createWidget($this,$className,$properties); $widget->init(); return $widget; } public function widget($className,$properties=array(),$captureOutput=false) { if($captureOutput) { ob_start(); ob_implicit_flush(false); $widget=$this->createWidget($className,$properties); $widget->run(); return ob_get_clean(); } else { $widget=$this->createWidget($className,$properties); $widget->run(); return $widget; } } /** * Creates a widget and executes it. * This method is similar to {@link widget()} except that it is expecting * a {@link endWidget()} call to end the execution. * @param string $className the widget class name or class in dot syntax (e.g. application.widgets.MyWidget) * @param array $properties list of initial property values for the widget (Property Name => Property Value) * @return CWidget the widget created to run * @see endWidget */ public function beginWidget($className,$properties=array()) { $widget=$this->createWidget($className,$properties); $this->_widgetStack[]=$widget; return $widget; } /** * Ends the execution of the named widget. * This method is used together with {@link beginWidget()}. * @param string $id optional tag identifying the method call for debugging purpose. * @return CWidget the widget just ended running * @throws CException if an extra endWidget call is made * @see beginWidget */ public function endWidget($id='') { if(($widget=array_pop($this->_widgetStack))!==null) { $widget->run(); return $widget; } else throw new CException(Yii::t('yii','{controller} has an extra endWidget({id}) call in its view.', array('{controller}'=>get_class($this),'{id}'=>$id))); } /** * Begins recording a clip. * This method is a shortcut to beginning {@link CClipWidget}. * @param string $id the clip ID. * @param array $properties initial property values for {@link CClipWidget}. */ public function beginClip($id,$properties=array()) { $properties['id']=$id; $this->beginWidget('CClipWidget',$properties); } /** * Ends recording a clip. * This method is an alias to {@link endWidget}. */ public function endClip() { $this->endWidget('CClipWidget'); } /** * Begins fragment caching. * This method will display cached content if it is availabe. * If not, it will start caching and would expect a {@link endCache()} * call to end the cache and save the content into cache. * A typical usage of fragment caching is as follows, * <pre> * if($this->beginCache($id)) * { * // ...generate content here * $this->endCache(); * } * </pre> * @param string $id a unique ID identifying the fragment to be cached. * @param array $properties initial property values for {@link COutputCache}. * @return boolean whether we need to generate content for caching. False if cached version is available. * @see endCache */ public function beginCache($id,$properties=array()) { $properties['id']=$id; $cache=$this->beginWidget('COutputCache',$properties); if($cache->getIsContentCached()) { $this->endCache(); return false; } else return true; } /** * Ends fragment caching. * This is an alias to {@link endWidget}. * @see beginCache */ public function endCache() { $this->endWidget('COutputCache'); } /** * Begins the rendering of content that is to be decorated by the specified view. * @param mixed $view the name of the view that will be used to decorate the content. The actual view script * is resolved via {@link getViewFile}. If this parameter is null (default), * the default layout will be used as the decorative view. * Note that if the current controller does not belong to * any module, the default layout refers to the application's {@link CWebApplication::layout default layout}; * If the controller belongs to a module, the default layout refers to the module's * {@link CWebModule::layout default layout}. * @param array $data the variables (name=>value) to be extracted and made available in the decorative view. * @see endContent * @see CContentDecorator */ public function beginContent($view=null,$data=array()) { $this->beginWidget('CContentDecorator',array('view'=>$view, 'data'=>$data)); } /** * Ends the rendering of content. * @see beginContent */ public function endContent() { $this->endWidget('CContentDecorator'); } } --- Добавлено --- Спойлер: CContentDecorator.php PHP: <?php class CContentDecorator extends COutputProcessor { public $view; public $data=array(); public function processOutput($output) { $output=$this->decorate($output); parent::processOutput($output); } protected function decorate($content) { $owner=$this->getOwner(); if($this->view===null) $viewFile=Yii::app()->getController()->getLayoutFile(null); else $viewFile=$owner->getViewFile($this->view); if($viewFile!==false) { $data=$this->data; $data['content']=$content; return $owner->renderFile($viewFile,$data,true); } else return $content; } } --- Добавлено --- Спойлер: landing.php PHP: <? $this->beginContent('//layouts/main2'); echo $content; $this->endContent(); ?>