Skip to content

Commit

Permalink
Support icon in ‘main_menu_custom_options’
Browse files Browse the repository at this point in the history
Add support for icon in main_menu_custom_options and update documentation.

Fixes #21414
  • Loading branch information
vboctor committed Aug 3, 2016
1 parent e64257c commit 61c56f5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
22 changes: 18 additions & 4 deletions config_defaults_inc.php
Expand Up @@ -3498,14 +3498,28 @@

/**
* Add custom options to the main menu. For example:
*
* $g_main_menu_custom_options = array(
* array( "My Link", MANAGER, 'my_link.php' ),
* array( "My Link2", ADMINISTRATOR, 'my_link2.php' )
* array(
* 'title' => 'My Link',
* 'access_level' => MANAGER,
* 'url' => 'my_link.php',
* 'icon' => 'fa-plug'
* ),
* array(
* 'title' => 'My Link2',
* 'access_level' => ADMINISTRATOR,
* 'url' => 'my_link2.php',
* 'icon' => 'fa-plug'
* )
* );
*
* Note that if the caption is found in custom_strings_inc.php, then it will be
* replaced by the translated string. Options will only be added to the menu
* Note that if the caption is a localized string name (in strings_english.txt or custom_strings_inc.php),
* then it will be replaced by the translated string. Options will only be added to the menu
* if the current logged in user has the appropriate access level.
*
* Use icons from http://fontawesome.io/icons/ - Add "fa-" prefix to icon name.
*
* @global array $g_main_menu_custom_options
*/
$g_main_menu_custom_options = array();
Expand Down
16 changes: 11 additions & 5 deletions core/layout_api.php
Expand Up @@ -823,11 +823,17 @@ function layout_config_menu_options_for_sidebar( $p_active_sidebar_page ) {
$t_custom_options = config_get( 'main_menu_custom_options' );

foreach( $t_custom_options as $t_custom_option ) {
$t_menu_option = array();
$t_menu_option['title'] = $t_custom_option[0];
$t_menu_option['access_level'] = $t_custom_option[1];
$t_menu_option['icon'] = 'fa-plug';
$t_menu_option['url'] = $t_custom_option[2];
if( isset( $t_custom_option['url'] ) ) {
$t_menu_option = $t_custom_option;
} else {
# Support < 2.0.0 custom menu options config format
$t_menu_option = array();
$t_menu_option['title'] = $t_custom_option[0];
$t_menu_option['access_level'] = $t_custom_option[1];
$t_menu_option['icon'] = 'fa-plug';
$t_menu_option['url'] = $t_custom_option[2];
}

$t_menu_options[] = $t_menu_option;
}

Expand Down
18 changes: 16 additions & 2 deletions docbook/Admin_Guide/en-US/config/html.xml
Expand Up @@ -129,8 +129,18 @@
the link to be executed. For example:
<programlisting>
$g_main_menu_custom_options = array(
array( 'My Link', MANAGER, 'my_link.php' ),
array( 'My Link2', ADMINISTRATOR, 'my_link2.php' ),
array(
'title' =&gt; 'My Link',
'access_level' =&gt; MANAGER,
'url' =&gt; 'my_link.php',
'icon' =&gt; 'fa-plug'
),
array(
'title' =&gt; 'My Link2',
'access_level' =&gt; ADMINISTRATOR,
'url' =&gt; 'my_link2.php',
'icon' =&gt; 'fa-plug'
)
);
</programlisting>
Note that if the caption is found in the
Expand All @@ -141,6 +151,10 @@ $g_main_menu_custom_options = array(
the current logged in user has the appropriate
access level.
</para>
<para>
Use icons from <ulink url="http://fontawesome.io/icons/">Font Awesome</ulink>.
Add "fa-" prefix to icon name.
</para>
</listitem>
</varlistentry>
</variablelist>
Expand Down

0 comments on commit 61c56f5

Please sign in to comment.