Adding a custom button the the Edit Toolbar in 5.5.1

Permalink
I've been struggling to try and get a custom button (a link to a Single Page of Training Videos for editors) added to the Edit Toolbar in C5 v5.5.1... and everything I've tried has failed.

I gave a shot using the Interface helper. No luck.

Then I tried the jQuery route to append an "<li>" to the "#ccm-main-nav" list, and that didn't work.

Has anyone successfully done this that could provide some pointers?

Thanks!

- John

arrestingdevelopment
 
kellyelton replied on at Permalink Reply
Check out the ProEvents plugin. Not sure how they do it, but they do.
kellyelton replied on at Permalink Best Answer Reply
arrestingdevelopment replied on at Permalink Reply
arrestingdevelopment
@kellyelton,

Thanks! This blog post looks like it's perfect!

I ended up doing something else for the site I was working on... but now that I have this, I may go back and "improve" it for them! ;D

Really appreciate the pointers!

- John
hereNT replied on at Permalink Reply
hereNT
Does anyone know how to do this with a link to another page? I want to make a package that will add an 'edit in composer' button for pages that support it. Seems like all the posts I find about it are for making a dialog, that's not what I want to do, I just want to link to the composer dashboard page.
sambrody24 replied on at Permalink Reply
sambrody24
There are two ways to do this

1.http://www.codeblog.ch/2012/04/concrete5-custom-toolbar-button/... this will not mess with the core of C5 which can be tricky

2. navigate to core concrete/tools/page_controls_menu.js
scroll down until you get to this code

<?php  if ($dh->canRead()) { ?>
   menuHTML += '<li><a class="ccm-icon-dashboard ccm-menu-icon" id="ccm-nav-dashboard<?php  if ($md->isMobile()) { ?>-mobile<?php  } ?>" href="<?php echo View::url('/dashboard')?>"><?php echo t('Dashboard')?></a></li>';
<?php  } ?>
menuHTML += '<li id="ccm-nav-intelligent-search-wrapper"><input type="search" placeholder="<?php echo t('Intelligent Search')?>" id="ccm-nav-intelligent-search" tabindex="1" /></li>';
menuHTML += '<li><a id="ccm-nav-sign-out" class="ccm-icon-sign-out ccm-menu-icon" href="<?php echo View::url('/login', 'logout')?>"><?php echo t('Sign Out')?></a></li>';
menuHTML += '</ul>';


copy and paste
menuHTML += '<li><a id="ccm-nav-sign-out" class="ccm-icon-sign-out ccm-menu-icon" href="<?php echo View::url('/login', 'logout')?>"><?php echo t('Sign Out')?></a></li>';


above the line that echoes <?php echo t('Intelligent Search')?>

and inside
('/login', 'logout')
place your url path to that page
PanAura replied on at Permalink Reply
PanAura
As a note on the 2nd option it is best to not edit any of the core system files. I recommend that anyone going to do the 2nd option simply copy the concrete/tools/page_controls_menu.js and then paste it into the "tools" folder outside of the core and then edit that file instead.

Here is my example of creating a help button next to the "edit" button on the toolbar.

menuHTML += '<li><a id="ccm-nav-edit" class="ccm-menu-icon" style="background-position:-13px -2362px !important;" href="<?php echo View::url('/index.php?cID=212')?>"><?php echo t('Help')?></a></li>';


Just copy the code above and place it in your file like I have in the example below:

menuHTML += '<li <?php  if ($c->isEditMode()) { ?>class="ccm-nav-edit-mode-active"<?php  } ?>><a class="ccm-icon-edit ccm-menu-icon" id="ccm-nav-edit" href="<?php  if (!$c->isEditMode()) { ?><?php echo DIR_REL?>/<?php echo DISPATCHER_FILENAME?>?cID=<?php echo $c->getCollectionID()?>&ctask=check-out<?php echo $token?><?php  } else { ?>javascript:void(0);<?php  } ?>" <?php  if (!$c->isEditMode()) { ?> onclick="$(\'#ccm-edit-overlay\').hide()" <?php  } ?>><?php  if ($c->isEditMode()) { ?><?php echo t('Editing')?><?php  } else { ?><?php echo t('Edit')?><?php  } ?></a></li>';
    menuHTML += '<li><a id="ccm-nav-edit" class="ccm-menu-icon" style="background-position:-13px -2362px !important;" href="<?php echo View::url('/index.php?cID=212')?>"><?php echo t('Help')?></a></li>';
   <?php 
   $items = $ihm->getPageHeaderMenuItems('left');
   foreach($items as $ih) {
      $cnt = $ih->getController(); 
      if ($cnt->displayItem()) {
      ?>
         menuHTML += '<li><?php echo $cnt->getMenuLinkHTML()?></li>';
      <?php 
      }
   }
} ?>