Yii Framework Forum: Move menu items from layout file - Yii Framework Forum

Jump to content

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

Move menu items from layout file Rate Topic: -----

#1 User is offline   Raouf Athar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 18-June 09
  • Location:Srinagar, India

Posted 24 August 2009 - 02:26 AM

Hi,

I want to remove the menu items of applications from main.php to somewhere else.

e.g.
array('label'=>'Home', 'url'=>array('/site/index')),
array('label'=>'Contact', 'url'=>array('/site/contact')),

I dont want to put it in the layout file "main.php". (with a little instruction) Please suggest which file is suited for keeping these items in?

Thanks
--
Posted Image
Raouf Athar
Srinagar, India
Yarikul.com
0

#2 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 24 August 2009 - 04:26 AM

Where do you want to place them afterwards? On all pages or specific ones?
0

#3 User is offline   Raouf Athar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 18-June 09
  • Location:Srinagar, India

Posted 24 August 2009 - 04:33 AM

View Postpestaa, on 24 August 2009 - 04:26 AM, said:

Where do you want to place them afterwards? On all pages or specific ones?


I want it to appear on all pages. I Just dont want the code in the main.php file. I suppose main.php file in the layouts is not suitable for this data.
--
Posted Image
Raouf Athar
Srinagar, India
Yarikul.com
0

#4 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 24 August 2009 - 06:29 AM

If we are talking about views/layouts/main.php, then that is your default layout. Unless you specify other layout in the controller (or no layout at all), this file will be used to enclose your generated output (placing the latter at $content placeholder).
0

#5 User is offline   Raouf Athar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 18-June 09
  • Location:Srinagar, India

Posted 24 August 2009 - 11:08 PM

View Postpestaa, on 24 August 2009 - 06:29 AM, said:

If we are talking about views/layouts/main.php, then that is your default layout. Unless you specify other layout in the controller (or no layout at all), this file will be used to enclose your generated output (placing the latter at $content placeholder).


Yes we are talking about views/layouts/main.php. mainmenu is a widget which processes the menu items which are passed as parameters from the main.php file. I don't want to place the code (parameters) for menu items here in the main.php and want to separate it from the layout file. Where can I put that?
--
Posted Image
Raouf Athar
Srinagar, India
Yarikul.com
0

#6 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 25 August 2009 - 01:50 AM

I see your question now. I'd put it in the configuration array, under 'params' key.

So you can later pass the arguments to the widget as Yii::app()->params['myMenuItems'];

Hope this helps.
0

#7 User is offline   thiagovidal 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 17-February 10
  • Location:Brazil, São Paulo

Posted 07 September 2010 - 06:01 PM

View PostRaouf Athar, on 24 August 2009 - 11:08 PM, said:

Yes we are talking about views/layouts/main.php. mainmenu is a widget which processes the menu items which are passed as parameters from the main.php file. I don't want to place the code (parameters) for menu items here in the main.php and want to separate it from the layout file. Where can I put that?


Hey dude. You can create a file separeted. and them call $this->renderPartial('psth/to/view'); on your views...

Simple!
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