(English) concrete5 – Custom Toolbar Button

Leider ist der Eintrag nur auf English verfĂĽgbar.




23 Comments

Awesome! Thanks, Remo! I was looking for this exact kind of thing a few months back… I needed to add a button into the toolbar to link to a “hidden” page of training videos. Looks like this would do the trick… just change the ‘href’ in the on_start function to point have the “http://path-to-videos” URL!

Thanks!

Hi Remo

First of all a big thank you for this guide. I wanted to create a button that would link to the Customize Theme window and have sort of got there but just the body content shows without the navigation or ccm-theme-style-attribute to change any colors.

I am using

‘href’ => REL_DIR_FILES_TOOLS_REQUIRED . ‘/themes/preview_internal?themeID=4&previewCID=1’,

But I am not sure if preview_internal? is the correct one to use. Please can you advise

Thanks

Hi Rob, I don’t really understand what you’re trying to achieve, but when you want to see the current page with a different page theme, you have to change the value of previewCID as well. It’s the internal page ID. You can find this id if you look at the code of a page and search for CCM_CID. The link you’ve posted will always show the home page.

Hi Remo,

I think what I am trying to achieve is a button that will open the Customize window for my current theme and get the same results as dashboard>themes>customize.

When I open in the usual route I check the source on the customize window and see /index.php/tools/required/themes/preview_internal?themeID=4&previewCID=1. I thought that if I put this in the Href as I gave before it should show the same results.

It does open the window but does not show the Div class ccm-pane-options at the top, which is where the options are to change the background styles etc. It does however show the main page which is what should be shown. So I am not sure if this is the correct href to use to open an equivalent of the Cusomize page or if indeed c5 uses this preview_internal.php to create the page.

Sorry but still trying to find my way around c5.

Okay, the problem is that when you’ve viewed the source, you had the mouse cursor in an iframe. This is why you just got the content and not the pane around it..
If you want to see the complete page, you’ll have to use /index.php/dashboard/pages/themes/customize/1/ Please note the last parameter which is the theme id. You can do this with $c->getCollectionThemeID()

This is really great, but I have one question:

How would you get this to work with a static link to a page? I’d like to make a package that simply links to the composer edit page if a page was created / enabled for composer. I don’t need to do a dialog at all.

Any thoughts on how to do this?

Hey Jeremy! Yes, this is also possible.
Basically in my example, I’m catching the click on the button with the little JavaScript. First option would be to replace it with something like this:

1
2
3
4
5
6
7
8
$(function() {
 
    $("#ccm-page-edit-nav-help").click(function(event) {
        event.preventDefault();
        window.location.href = "http://composer.oi.ai"
    });    
 
});

However, you could also use an old fashioned link, don’t run any JavaScript code and simple use the standard href attribute. The package controller method on_start would then look like this:

1
2
3
4
5
6
7
8
9
10
11
12
   public function on_start() {
      if(version_compare(APP_VERSION,'5.4.1.1', '>')){
         $ihm = Loader::helper('concrete/interface/menu');
         $uh = Loader::helper('concrete/urls');
 
         $ihm->addPageHeaderMenuItem('help', t('Help'), 'left', array(
            'dialog-title'    => t('Help'),
            'href'            => 'http://www.google.com',
            'target'          => '_blank'
         ), 'remo_toolbar_button');         
      }   
   }

By the way, I also think that the composer needs a few tiny things. It’s already a great feature but I never liked that I had to navigate through the sitemap to edit an existing page using the composer. My approach to improve this was a bit different but I think both ideas can work great. Check out this add-on: https://github.com/Remo/concrete5-composer-list

Hey Remo,

1. Loved your new book, took my C5 abilities to a new level

2. Thank you for this tutorial, I think a lot of developers forget that clients have trouble understanding actions that take more then 1 or 2 levels of interaction to get to. Tutorials like this help us solve real problems for them.

Hey Remo,

I am having a devil of a time with this

Okay, the problem is that when you’ve viewed the source, you had the mouse cursor in an iframe. This is why you just got the content and not the pane around it..
If you want to see the complete page, you’ll have to use /index.php/dashboard/pages/themes/customize/1/ Please note the last parameter which is the theme id. You can do this with $c->getCollectionThemeID()

Would it be possible for me to see an example?

I am also trying to open theme customization in that window.

-Sam

Sam, I haven’t found time to create an example about the customize theme issue yet but I think I know why only one package works. There’s an ID in the code (ccm-page-edit-nav-help). This has to be unique across the whole page and thus every package as well. Have you or can you try to replace that ID in package 2-4 with something different?

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *