Yii Framework Forum: Refactoring views - Yii Framework Forum

Jump to content

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

Refactoring views Rate Topic: -----

#1 User is offline   anthony 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 13-May 10

Posted 13 May 2010 - 03:38 AM

Hello. I'm new to Yii and MVC in general. Not new to PHP/MySQL.

I've been given the task of refactoring the code-base powering the admin interface of one of our web applications and I'm just after some pointers. The application was written in a bit of a hurry and some of the page-display code has ended up in unexpected places, and it is my job to put this right.

The problem is the main menu. There is a main menu at the top of each page (Home, To Do, Products, News, and Manufacturers). I am writing the "Manufacturer" section, and I added the manufacturer entry to the menu bar in file "<app-root>\themes\classic\views\layouts\main.php" (using the Main Menu widget). The problem is that on some of the sections ("Home" and "To Do"), my new entry is not appearing. The guy who gave me the job mentioned that he "copied and pasted" some code, so I guess these pages are drawing their menu-generation code from more model-specific template areas.

My question is where might he have put such code? Where might Yii be calling it from? I'm sorry that I do not know more about Yii to give more details...

Many thanks,

Anthony
0

#2 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 13 May 2010 - 05:03 AM

Usually the main menu' should be in the layout (views/layout/main.php).

There can be more layouts, you can check in the controllers if the are using different layout, or the menu can simply be replicated in all views.

If is replicated, the best idea is to put in the layout andd to delete from all pages in wich the menu' has been copied.
0

#3 User is offline   anthony 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 13-May 10

Posted 14 May 2010 - 06:15 AM

Thanks for your help. I'm getting more of a handle on it now. There are a few different page template files with their own menus hard-coded in, and conditional "if($this->id=='product')" content - yuck. Some of these are modified "classic" theme files, and some are in the controllers' view files directories.

According to Yii convention, should the theme directory files be modified, or should I force each controller to look for view files under the protected directory?

EDIT: One more thing: There are two main layouts, one-column and two-column. At the moment they call two different generic page templates, "main.php" and "one-column.php". Is there an easy way of just getting them to call one generic template and specifying the columns elsewhere?

Many thanks,

Anthony
0

#4 User is offline   anthony 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 13-May 10

Posted 14 May 2010 - 09:14 AM

Found this page. http://www.yiiframew...oc/cookbook/28/ What a great framework!
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