Custom Front End Admin Menu
Permalink
Not sure if someones done this before but thought i'd share. I've created a block recently that I wanted to have an extra menu item on the front end editor so the client didn't need to do some functions in the dashboard. Here's what i did:
First i opened up the /concrete/elements/block_controls.php file and added the following around line 49 or so right after the "canDelete" bit:
Then I opened up /concrete/js/ccm.ui.js file and added this bit around line 59 right before the "canWrite" if statement:
Now after I did that I was able to define a custom menu item in my blocks controller.php file within the __construct function like so:
That's it now you can create custom front end menu items. Have fun!
First i opened up the /concrete/elements/block_controls.php file and added the following around line 49 or so right after the "canDelete" bit:
<?php } if ($c->isMasterCollection()) { ?> ccm_menuObj<?php echo $id?>.canAliasBlockOut = true; <?php }
Then I opened up /concrete/js/ccm.ui.js file and added this bit around line 59 right before the "canWrite" if statement:
if (obj.hasCustomMenu) { $.each(obj.hasCustomMenu, function(i, val) { html += '<li><a class="ccm-icon" dialog-title="' + val.menuText + '" dialog-modal="true" dialog-width="' + obj.width + '" dialog-height="' + obj.height + '" id="menu' + val.menuID + obj.bID + '-' + obj.aID + '" href="' + CCM_TOOLS_PATH + '/edit_block_popup.php?cID=' + CCM_CID + '&bID=' + obj.bID + '&arHandle=' + obj.arHandle + '&btask=' + val.menuAction +'"><span style="background-image: url(' + CCM_IMAGE_PATH + '/icons/' + val.menuIcon + '_small.png)">' + val.menuText + '</span></a></li>'; }); html += '<li class="header"></li>'; }
Now after I did that I was able to define a custom menu item in my blocks controller.php file within the __construct function like so:
$this->customMenuItems = '[{menuID:"theMenusId", menuAction:"theActionToCall" , menuIcon:"theIconToUse", menuText:"The text of the menu item."}]'; $this->set('thisCustomMenu', $this->customMenuItems);
That's it now you can create custom front end menu items. Have fun!