Add features to navigation bar
- 2015-09-14 15:07:15
- azalea
- 9020
- Last edited by xiying guan on 2018-12-06 10:10:34
1. Navigation bar
The navigation bar in ZenTao includes three parts, the top menu, the module menu and the function module.
2. Define a menu
The code of menu definition is saved in the language files in zentao/module/common/lang/zh-cn. Now let’s look at the definition of the main menu.
2.1 Define a main menu
80 $lang->menu- > my = 'Dashboard|my|index';81 $lang- > menu- > product = 'Product|product|index';
82 $lang- > menu- > project = 'Project|project|index';
83 $lang- > menu- > qa = 'Testing|index';
Let’s look at the definition of codes 83 $lang- > menu- > qa = 'Testing|qa|index';
It defines the codeof the Testing module. menu->qa defines the key value of the menu, which can be defined according to the actual definition of modules. The three parameters separated by the vertical lines are the text of the menu, the corresponding module and the method. This code is to define a top menu, the text of which is Testing, and link its index method to qa module.
2.2
Define a module menu
Take the module menu of Product as an example.
144 $lang->product-
>
menu-
>
list = '%s';
145 $lang-
>
product-
>
menu-
>
story = array('link' =
>
'Story|product|browse|productID=%s', 'subModule' =
>
'story');
155 $lang-
>
product-
>
menu-
>
create = array('link' =
>
' Newly added product|product|create', 'float' =
>
'right');
158 $lang-
>
productplan-
>
menu = $lang-
>
product-
>
menu;
159 $lang-
>
release-
>
menu
= $lang-
>
product-
>
menu;
These codes define the module menu in the Product and there are some new definition among them.
2.2.1 Define links with arrays
145 $lang-
>product-
>menu-
>story =
array('link' =
>
'Story|product|browse|productID=%s', 'subModule' =
>'story');
It defines two elements with array: link and subModule. One parameter field is added, productID=%s, which means the browse method used when linking the story menu to the Product. The parameter passed is productID=%s, and %s will be changed into the actual product ID.
2.2.2 Define submodules
145 $lang-
>product-
>menu-
>story = array('link' =
> 'Story|product|browse|productID=%s',
'subModule' =
>
'story');
It is used to define submodules and highlight it. When you are visiting story module, the defined menu Product is kept highlighted.
2.2.3 Define method alias with Alias
151 $lang-
>product-
>menu-
>view = array('link' =
>'Overview|product|view|productID=%s',
'alias' =
>
'edit');
alias means that the edit page and view page of the product are the same. Therefore, when you edit products, the Overview is still highlighted.
2.2.4 Define the settings of menu
Every menu is displayed at the left by default. If you want to move it to the right, you have to define its float parameter.
155 $lang-
>product-
>menu-
>create = array('link' =
>'newly added product|product|create',
'float' =
>
'right');
By setting float, you define that the link of the newly added product will be displayed on the right.
2.3 Define a function menu
Function module is printed in the each module. Its extension method is the same as that of views, which we will discuss later.
3. Define menu sequence
What have been mentioned above is how to define a menu in ZenTao. Now we will talk about how to define menu sequence in ZenTao. In the directory of common/lang/, there is menuOrder.php which is used to define the display sequences of each menu./* Sort of main menu. */
$lang->menuOrder[5] = 'my';
$lang- >menuOrder[10] = 'product';
$lang->menuOrder[15] = 'project';
$lang->menuOrder[20] = 'qa';
$lang->menuOrder[25] = 'doc';
$lang->menuOrder[30] = 'report';
$lang->menuOrder[35] = 'company';
$lang->menuOrder[40] = 'admin';
/* index menu order. */
$lang->index->menuOrder[5] = 'product';
$lang->index->menuOrder[10] = 'project';
4. How to add your pages to the menu
Once you understand the menu mechanism in ZenTao, it will be very easy to extend. Let’s look at the steps to ad pages to menu.4.1 Create a file in the directory of module/common/ext/lang/zh-cn/. It can be abc.php and you can name it at your wish.
4.2 Add your own menu to the file, e.g. the build repository menu in the ZenTao Pro.
$lang->menu->repo = ' build repository |repo|browse';
$lang->menuOrder[21] = 'repo';
$lang->repo->menu->list = '%s' . $lang->arrow;
$lang->repo->menu->browse = array('link' =>'browse|repo|browse|repoID=%s', 'alias' =>'diff, log, view, revision, showsynccomment');
$lang->repo->menu->settings = 'settings|repo|settings|repoID=%s';
$lang->repo->menu->delete = array('link' =>'delete|repo|delete|repoID=%s', 'target' =>'hiddenwin');
$lang->repo->menu->create = array('link' =>' newly added build repository |repo|create|', 'float' =>'right');