Converting Custom Menu Hook

From TNG_Wiki
Jump to: navigation, search
Ambox notice.png The Converting Custom Menu Hook page provides information on how to convert the Custom Menu Hook syntax introduced in TNG V9 to using the syntax used by the Custom Drop Down Menu mod

The information is provided to help you convert any Site Menu Mod you were using to the new Custom Menu Hook Mod

TNG 10.0

Menu Title

TNG version: 10.0

Using the TNG V9, Custom Menu Hook you have to specify that you want a $custommenu using the following syntax

// Site Menu mod added to customconfig.php in TNG V9
// Note that the following lines include double-escapes
// required for the eval of the $custommenu in genlib.php

    $custommenu .= "\$menu .= \"<li><a href=\\\"#\\\" class=\\\"menulink\\\">{\$text['mysite']}</a>\";";
    $custommenu .= "\$menu .= \"<ul class=\\\"last\\\">\";";

The Custom Drop Down Menu mod simplifies that by only requiring that you specify the title to be used for your site menu, which can be

  • a literal
$custmenu['title_text'] = "More";
  • or custom text for each of your languages
//        Custom Drop Down Menu added to customconfig.php in TNG V10
$custmenu['title_index'] = "mysite";

$text['mysite'] = "More";

First Entry

Each entry for the Custom Menu Hook must be specified using PHP code

    $custommenu .= "\$menu .= tngddrow(\"{\$cms['tngpath']}user/research_resources.php\", \"research\", \"user/images/my_resources.gif\", \"myresearch\");";

whereas entries for the Custom Drop Down Menu only require you to specify the text portion for the target (link), icon, and label which can be a literal using ['label_text'] or custom text using ['label_index']

$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";

Subsequent Entries

Each entry for the $custommenu in customconfig.php must be specified as a php code fragment from genlib.php

    $custommenu .= "\$menu .= tngddrow(\"{\$cms['tngpath']}../maine/index.php\", \"maine-cemeteries\", \"user/images/steluce.ico\", \"mainecemeteries\");";

Note that the Custom Drop Down Menu entry allows you to sue the TNG sprite, such as the cemeteries-icon below

$link_nr++; // increment the number for each additional link (2)
$custommenulinks[$link_nr]['target'] = "../maine/index.php";
$custommenulinks[$link_nr]['sprite'] = "cemeteries-icon";
$custommenulinks[$link_nr]['label_index'] = "mainecemeteries";

Optionally, you can also add parameters that request the link be opened in a new window or be restricted to Admin users

$custommenulinks[$link_nr]['newwin'] = true;
$custommenulinks[$link_nr]['admin'] = true;