E
E
EVOSandru62015-07-10 08:23:01
Yii
EVOSandru6, 2015-07-10 08:23:01

How can I switch from one subpattern to another in different modules?

Good afternoon,
I want to have several subtemplates in the created admin module. Created so far 4 - Default column1 and column2 and duplicated them column1-admin and column2-admin

class AdminModule extends CWebModule
{
  public function init()
  {
        $this->layout =  '/layouts/main';
  }
}

class DefaultController extends Controller
{
  public function actionIndex()
  {
        $this->layout = '//layouts/column1';
    $this->render('index');
  }

    public function actionView()
    {
        $this->layout = '//layouts/column2';
        $this->render('index');
    }
}

column1.php
<?php $this->beginContent('//layouts/main'); ?>
<div id="content">
    column1
  <?php echo $content; ?>
</div><!-- content -->
<?php $this->endContent(); ?>

column2.php
<?php $this->beginContent('//layouts/main'); ?>
<div class="span-19">
  <div id="content">
        column2
    <?php echo $content; ?>
  </div><!-- content -->
</div>
<div class="span-5 last">

  <div id="sidebar">

  <?php
    $this->beginWidget('zii.widgets.CPortlet', array(
      'title'=>'Operations',
    ));
    $this->widget('zii.widgets.CMenu', array(
      'items'=>$this->menu,
      'htmlOptions'=>array('class'=>'operations'),
    ));
    $this->endWidget();
  ?>
  </div><!-- sidebar -->
</div>
<?php $this->endContent(); ?>

In my default controller, none of the action outputs the word: column1 or column2.
I tried to write in the init of the module like here vispyanskiy.name/ru/kak-zadat-shablon-dlya-modulya... :
$this->layoutPath = Yii::getPathOfAlias('admin.views.layouts');
$this->layout = 'main';

Then I tried to set the path from the DefaultController actions :
$this->layout = 'admin.views.layouts.main.column1';

I fly into the text with my content, but without styles, i.e. The topic is not included.
On the advice of this Chinese https://www.youtube.com/watch?v=Nc0ED8_VsT4 :
Commented out in protected/components/Controller.php :
// public $layout = '//layouts/column1';
But it didn't help.
I can easily connect to this view:
admin.views.layouts.main
But it's not so interesting, I want to take subtemplates as well.
Help me please.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question