Yii Framework Forum: Arguments passing - Yii Framework Forum

Jump to content

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

Arguments passing Rate Topic: -----

#1 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 10 May 2010 - 04:19 AM

Hi!

How could I passing the variables into the layout file from the view? In the main.php layout I have the html:

<div class="title"><?php echo $pagetitle; ?></div>


And from different views I need to pass the different titles to the layout. For example, from main page I pass the "Home" value, from admin panel I pass "Administration panel" title.
0

#2 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 10 May 2010 - 05:25 AM

In your layout file
<?php
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
?>


And in your site controllers in the index action
<?php
$this->pageTilte = "Home";
?>

In your admin controller
<?php
$this->pageTilte = "Administration";
?>

etc
1

#3 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 10 May 2010 - 05:43 AM

Spyros, thanks.

With page titles it works fine! But now I need one more variable to passing.

In the layout I write:
<div><?php echo CHtml::encode($this->headline); ?></div>


And in the view:
<?php $this->headline = "Admin panel"; ?>


It leads to exception:
Property "AdminController.headline" is not defined.

0

#4 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 10 May 2010 - 05:45 AM

In your admin controller add
public $headline;
1

#5 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 10 May 2010 - 06:44 AM

View PostSpyros, on 10 May 2010 - 05:45 AM, said:

In your admin controller add
public $headline;

Thank you pal
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