Difference between revisions of "Custom Menu Hook"
(updated for TNG V10) |
(→Menu Entries: clarify $custom, $info, $find, and $media variable names) |
||
Line 55: | Line 55: | ||
* restricted to admin only | * restricted to admin only | ||
* opens in new window | * opens in new window | ||
+ | Menu entries are created based on the beginning of the variable name as follows: | ||
+ | * $custom... in the 4th custom pull down menu | ||
+ | * $find... as an addition in the Find pull down menu | ||
+ | * $media... as an addition in the Media pull down menu | ||
+ | * $info... as an addition in the Info pull down menu | ||
==== Link Number ==== | ==== Link Number ==== | ||
Line 69: | Line 74: | ||
$link_nr++; // increment the number for each additional link | $link_nr++; // increment the number for each additional link | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | or using $link_nr=n; where n is a number | ||
==== Target ==== | ==== Target ==== | ||
Line 74: | Line 81: | ||
The target parameter specifies where the link will point relative to your genealogy URL | The target parameter specifies where the link will point relative to your genealogy URL | ||
<syntaxhighlight lang="php" enclose="div"> | <syntaxhighlight lang="php" enclose="div"> | ||
− | $ | + | $custommenulinks[$link_nr]['target'] = "extensions/fgw/index.php"; |
</syntaxhighlight> | </syntaxhighlight> | ||
Line 82: | Line 89: | ||
<syntaxhighlight lang="php" enclose="div"> | <syntaxhighlight lang="php" enclose="div"> | ||
− | $ | + | $custommenulinks[$link_nr]['icon'] = "img/families_icon.gif"; |
</syntaxhighlight> | </syntaxhighlight> | ||
The assigned value is a path to a valid icon file and it is relative to (that is, starts in) the TNG root directory or your Genealogy URL. | The assigned value is a path to a valid icon file and it is relative to (that is, starts in) the TNG root directory or your Genealogy URL. | ||
Line 88: | Line 95: | ||
Another option is to use a sprite. | Another option is to use a sprite. | ||
<syntaxhighlight lang="php" enclose="div"> | <syntaxhighlight lang="php" enclose="div"> | ||
− | $ | + | $custommenulinks[$link_nr]['sprite'] = "fsearch-icon"; |
</syntaxhighlight> | </syntaxhighlight> | ||
TNG sprites are defined by id in genstyle.css. The id in the example above is 'fsearch-icon'. If you are an advanced user, you can provide your own sprites and CSS id's. If both an icon and sprite are given, the icon will take precedence. | TNG sprites are defined by id in genstyle.css. The id in the example above is 'fsearch-icon'. If you are an advanced user, you can provide your own sprites and CSS id's. If both an icon and sprite are given, the icon will take precedence. | ||
Line 97: | Line 104: | ||
<syntaxhighlight lang="php" enclose="div"> | <syntaxhighlight lang="php" enclose="div"> | ||
− | $ | + | $custommenulinks[$link_nr]['label_text'] = "Submit Family"; // literal text |
</syntaxhighlight> | </syntaxhighlight> | ||
or a pointer to the text in your cust_text.php file | or a pointer to the text in your cust_text.php file | ||
<syntaxhighlight lang="php" enclose="div"> | <syntaxhighlight lang="php" enclose="div"> | ||
− | $ | + | $custommenulinks[$link_nr]['label_index'] = "subfam"; // text from $text['subfam']; |
</syntaxhighlight> | </syntaxhighlight> | ||
Line 110: | Line 117: | ||
<syntaxhighlight lang="php" enclose="div"> | <syntaxhighlight lang="php" enclose="div"> | ||
− | $ | + | $custommenulinks[$link_nr]['admin'] = true; |
</syntaxhighlight> | </syntaxhighlight> | ||
Line 119: | Line 126: | ||
<syntaxhighlight lang="php" enclose="div"> | <syntaxhighlight lang="php" enclose="div"> | ||
− | $ | + | $custommenulinks[$link_nr]['newwin'] = true; |
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 05:56, 7 June 2016
The information provided here is for constructing your Custom Menu in TNG V10 and above or for adding an entry to one of the TNG existing pull down menu. Custom Menu Hook Mod provides a sample mod that uses the Custom Drop Down Menu mod syntax from TNG V9. |
|
Purpose
The purpose of the Custom Menu Hook in TNG V10 is to make it easier to add a Site or 4th pull down menu without having to modify the TNG code.
It also makes it easier to add new entries to an existing TNG pull down menu, such as the Find, Media, or Info menus.
Its purpose is not to provide information on how to modify existing TNG pull down menu entries nor the language pull down menu.
For information on the previous hook see Custom Menu Hook V9
Parameters
Menu Title
The first line for your custom menu in your customconfig.php file defines your menu title.
Literal
The following line shows the use of a Literal for your custom title.
$custmenu['title_text'] = "More";
Variable
If you use multiple languages on your site, then you should use the title_index option for your title where the value specified is the $text['more'] found in your cust_text.php file for the current language.
$custmenu['title_index'] = "more";
Of course, the administrator must define $text['more'] = "More"; in the cust_text.php file or it won't work.
Menu Entries
Each menu entry line of the custom menu is generated by specifying a
- link number
- target
- icon
- label
and optionally specifying whether the link is
- restricted to admin only
- opens in new window
Menu entries are created based on the beginning of the variable name as follows:
- $custom... in the 4th custom pull down menu
- $find... as an addition in the Find pull down menu
- $media... as an addition in the Media pull down menu
- $info... as an addition in the Info pull down menu
Link Number
The first link in the menu is always number 0, specified as
$link_nr=0; // the first link in the menu is always number 0
Additional links in the menu are specified by incrementing the link_nr, specified as
$link_nr++; // increment the number for each additional link
or using $link_nr=n; where n is a number
Target
The target parameter specifies where the link will point relative to your genealogy URL
$custommenulinks[$link_nr]['target'] = "extensions/fgw/index.php";
Icon
You will probably want an icon displayed with the menu item. There are two options, one using a traditional icon file, the other using a sprite. We can assign a traditional icon to the link by adding the following line to the link definition:
$custommenulinks[$link_nr]['icon'] = "img/families_icon.gif";
The assigned value is a path to a valid icon file and it is relative to (that is, starts in) the TNG root directory or your Genealogy URL.
Another option is to use a sprite.
$custommenulinks[$link_nr]['sprite'] = "fsearch-icon";
TNG sprites are defined by id in genstyle.css. The id in the example above is 'fsearch-icon'. If you are an advanced user, you can provide your own sprites and CSS id's. If both an icon and sprite are given, the icon will take precedence.
Label
The label parameter can either be a literal
$custommenulinks[$link_nr]['label_text'] = "Submit Family"; // literal text
or a pointer to the text in your cust_text.php file
$custommenulinks[$link_nr]['label_index'] = "subfam"; // text from $text['subfam'];
Admin
Admin is an optional parameter than can be used to restrict a link to site admins. Anyone else who is not logged in with admin privileges will be unable to see or access it.
$custommenulinks[$link_nr]['admin'] = true;
New Window
The newwin is an optional parameter that indicates that you want this link to open in a new browser window or tab (browser dependent).
$custommenulinks[$link_nr]['newwin'] = true;
External Link
The external is an optional parameter that indicates that your menu item will take you to another website, where you will need to set an option as follows:
$infomenulinks[$link_nr]['external'] = true;
Add Tool Tips
Optionally, if you would like your menu items to display a tool tip, there are two options -- one where you can directly enter the text into your link definition, and another to use language support by adding it to the $text array in the cust_text.php files.
This option will use the text as given for the tool tip.
$infomenulinks[$link_nr]['tip_text'] = "Submit your family history for inclusion."
This next option will look in your current language $text array for $text['tip_subfam'].
$infomenulinks[$link_nr]['tip_index'] = "subfam"; // $text['tip_subfam']
Menu Option
The TNG V10 Custom Menu Hook allows you to add to the existing TNG pull down menus or to create a custom menu. Each menu is associated with its own array:
- $infomenulinks is an array that will contain all the configurations for links to be inserted into the TNG Info menu.
- $findmenulinks is for adding items to the Find menu
- $mediamenulinks is for adding menu items to the Media menu, although normally additions here would be using user Media Collections.
- $custommenulinks is for adding menu items to your custom menu.
Sprite
Darrin has provided two different sprite icons for the Mobile Mode Display
If you want to use the plus sign icon, then rename
|
|
Custom Menu Construction
Menu Title
The title line of the custom menu if you are a multi-language site should use the title_index option
$custmenu['title_index'] = "mysite";
The title line of the custom menu if you are a single language site can use the title_text opion
$custmenu['title_text'] = "Site";
Menu Entries
Each menu entry line of the custom menu is generated by specifying a
- target
- icon
- label
$link_nr=0; // the first link in the menu is always number 0
$custommenulinks[$link_nr]['target'] = "user/research_resources.php";
$custommenulinks[$link_nr]['icon'] = "user/images/my_resources.gif";
$custommenulinks[$link_nr]['label_index'] = "myresearch";
for each entry being generated. The $link_nr should be incremented using $link_nr++;
$link_nr++; // increment the number for each additional link (1)
$custommenulinks[$link_nr]['target'] = "guestbook.ph";
$custommenulinks[$link_nr]['icon'] = "user/images/my_guestbook.gif";
$custommenulinks[$link_nr]['label_index'] = "myguestbook";
Custom Menu Example
Using TNG Mod
The Custom Menu Hook Mod can be used to installed your site custom menu in the customconfig.php file. If you don't want to use the Mod Manager to install your TNG customization, see the Manual update of customconfig.php file below.
TNG V10 zip file for the Custom Hook Menu Mod is included here for convenience [ custom_hook_menu_example_v10.0.0.0.zip]]
Note that no attempt was made to incorporate the Tray of Sprites capability in the sample menu.
Manual update
The following is an example of how you would code your custom site menu in customconfig.php. If you prefer to use the Mod Manager to install all your changes to TNG, then you should use the Custom Hook Menu Mod
Note that the code shown below is identical to what is added to the customconfig.php file if you install the Site Menu Mod
// Custom HooK Menu added to customconfig.php in TNG V10
// For additional details see the TNG Wiki <a href="http://tng.lythgoes.net/wiki/index.php?title=Custom_Menu_Hook" target="_blank">Custom Menu Hook</a>.
$custmenu['title_index'] = "mysite";
$link_nr=0; // the first link in the menu is always number 0
$custommenulinks[$link_nr]['target'] = "user/research_resources.php";
$custommenulinks[$link_nr]['icon'] = "user/images/my_resources.gif";
$custommenulinks[$link_nr]['label_index'] = "myresearch";
$link_nr++; // increment the number for each additional link (1)
$custommenulinks[$link_nr]['target'] = "guestbook.ph";
$custommenulinks[$link_nr]['icon'] = "user/images/my_guestbook.gif";
$custommenulinks[$link_nr]['label_index'] = "myguestbook";
Adding to Find
The following is an example of how you would add the Census Plus International mod Find to the TNG Find pull down menu and restrict its access to those with TNG Admin privileges.
$link_nr = 0;
$findmenulinks[$link_nr]['target'] = "admin_censusplus.php";
$findmenulinks[$link_nr]['icon'] = "img/cpsprite.jpg";
$findmenulinks[$link_nr]['label_index'] = "mycensus"; // text from $text['mycensus'];
$findmenulinks[$link_nr]['newwin'] = true;
$findmenulinks[$link_nr]['admin'] = true;
Adding to Info
The following is an example of how you would add a Site How To link to the TNG Info pull down menu and open it in a new window.
$link_nr = 0;
$infomenulinks[$link_nr]['target'] = "user/how_to.php";
$infomenulinks[$link_nr]['icon'] = "user/images/question.jpg";
$infomenulinks[$link_nr]['label_index'] = "myhowto"; // text from $text['myhowto'];
$infomenulinks[$link_nr]['newwin'] = true;