ADDING LINKS TO THE CMSB INTERFACE USING THE MODIFYHEADERLINKS PLUGIN *WAS CALLED EXAMPLEHEADERLINKS* - Mar 27th, 2019


Since the header_links hook has been removed from CMSB starting with the release of version 3.0, Dave Edis from
Interactive Tools has shared a new version of the examplHeaderLinks plugin called modifyHeaderLinks.php that allows the
addition of custom links in the upper left portion of the main CMSB management interface page.

Here's Dave's plugin code:

<?php


// NOTE: RENAME this plugin so when you download updates you don't OVERWRITE your changes!!!

addFilter('menulinks_myAccount', 'modifyHeaderLinks');

//
function modifyHeaderLinks($menuArray) {

// Example of custom menu:


// remove license link
foreach ($menuArray as $index => $menuAttr) {
if (
preg_match("/\b(menu=license)\b/", @$menuAttr['link'])) { unset($menuArray[$index]); }
}

// add links to the beginning
$newMenu = [
'menuName' => t('New Menu'),
'menuType' => 'custom',
'link' => "?menu=new_menu",
'visibility' => 'requireLogin', // will be displayed in the user is logged in
'isSelected' => (@$_REQUEST['menu'] == 'new_menu'), // set to true to show this menu as selected
'br_after' => true, // optional: add line break after menu item instead of
separator ("|")
];
array_unshift($menuArray, $newMenu);

// add links to the end
$newMenu = [
'menuName' => 'Google',
'menuType' => 'custom',
'link' => "https://www.google.com/",
'isSelected' => false, // set to true to show this menu as selected
'linkTarget' => '_blank', // optional: set this to open link in a new tab
'visibility' => 'showAlways', // will be displayed always
];
array_push($menuArray, $newMenu);

return
$menuArray;
}

// eof


I was a bit confused as to how to implement the plugin until Daniel Louwe, a programmer at Interactive Tools came to my
rescue.

Daniel said:

"For adding these external links before the 'My Account' link , you would use something like this:

$newMenu = [
'menuName' => 'The Free Pixlr On-Line Image Editors &gt;&gt;',
'menuType' => 'custom',
'link' => "http://pixlr.com/express/",
'isSelected' => false,
'linkTarget' => '_blank',
'visibility' => 'showAlways',
'br_after' => true,
];
array_unshift($menuArray, $newMenu);

$newMenu = [
'menuName' => 'How to Use Pixlr Express &gt;&gt;',
'menuType' => 'custom',
'link' => "http://www.elleschorrphotography.com/using-pixlr.php",
'isSelected' => false,
'linkTarget' => '_blank',
'visibility' => 'showAlways',
'br_after' => true,
];
array_unshift($menuArray, $newMenu);


And to add external links after the 'View Website' link

$newMenu = [
'menuName' => 'COMPLETE IMAGEUPLOADING INSTRUCTIONS >> ',
'menuType' => 'custom',
'link' => "http://www.yoursite.com/faqdetails.php?21",
'isSelected' => false, // set to true to show this menu as selected
'linkTarget' => '_blank', // optional: set this to open link in a new tab
'visibility' => 'showAlways', // will be displayed always
'br_after' => true,
];
array_push($menuArray, $newMenu);

$newMenu = [
'menuName' => 'UPLOAD YOUR NEW IMAGES ORREVISE EXISTING SUBMISSIONS >> ',
'menuType' => 'custom',
'link' => "http://www.yoursite.com/cmsAdmin/admin.php?menu=exhibition_submissions",
'isSelected' => false, // set to true to show this menu as selected
'linkTarget' => '_blank', // optional: set this to open link in a new tab
'visibility' => 'showAlways', // will be displayed always
'br_after' => true,
];
array_push($menuArray, $newMenu);

As you can see, you can keep using the $newMenu variable name - simply call either array_unshift($menuArray, $newMenu)
(
add before the 'My Account' link) or array_push($menuArray, $newMenu) (add after the 'View"Website' link) after each
option array definition to add it to the menu.

In answer to "how would I set the following line to TRUE?
'isSelected' => (@$_REQUEST['menu'] == 'new_menu'), // set to true to show this menu as selected
"
Daniel offered the following:

This is only necessary for links that point to pages within CMSB and is mostly done automatically. You would just need
to make sure that the value in that line matches the "menu=" value in the link option. For example:

'link' => "?menu=example",
'isSelected' => (@$_REQUEST['menu'] == 'example'),



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service