Yii Framework Forum: Layout With Two Contents Part ? Possible ? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Layout With Two Contents Part ? Possible ? Rate Topic: -----

#1 User is offline   manhooei 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 13-September 11

Posted 23 February 2013 - 06:56 PM

I created the main.php under layout, Then I created a separate index.php for my registration form. I want my landing page/site index page be like facebook, with a registration form and a login form on the top tool bar.

The problem I'm facing is, I don't know how to integrate the two in the same layout. I already used the $content
for the registration form, I need to know how I can create another variable that can be used for the login form ?

Please let me know if there is any way around it. I appreciate it.

Thanks
Alex
0

#2 User is offline   seenivasan 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 620
  • Joined: 17-June 12
  • Location:Chennai,TamilNadu,India.

Posted 24 February 2013 - 03:35 AM

Dear Friend

I am not able to comprehend the exact requirement of yours.

Anyway let us consider that we have a layout test in views/layouts.

<!-- for login  -->
<div style="height:100px;width:800px;background:tan;">
    <?php echo $login;?>
</div>

<!-- for registeration-->
<div style="height:400px;width:400px;background:aliceBlue;">
    <?php echo $register;?>
</div>



Now in a controller and in some action we can do the following.
public function actionSomeAction()
{   $this->layout="//layouts/test";
    $register=$this->renderPartial("register",array(),true,true);//getting the registeration form along with scripts.
    $login=$this->renderPartial("login",array(),true,true);//getting loginform form along with scripts.
    $this->renderFile($this->getLayoutFile($this->layout),array('register'=>$register,'login'=>$login),false);
}


If you want to embed the test layout in any other layouts like main layout,
we can do the following.
<?php $this->beginContent("//layouts/main");?>
<!-- for login  -->
<div style="height:100px;width:800px;background:tan;">
    <?php echo $login;?>
</div>

<!-- for registeration-->
<div style="height:400px;width:400px;background:aliceBlue;">
    <?php echo $register;?>
</div>
<?php $this->endContent();?>


I hope I helped a bit.

Regards.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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