Skip to content

milangress/panel-bar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Panel Bar for Kirby CMS

Release Issues License Moral License

This plugin enables you to include a panel bar on top of your site which gives you direct access to some administrative functions. The panel bar will only be visible to logged in users who are eligible to access the panel.

Panel Bar in action

The plugin is free. However, I would really appreciate if you could support me with a moral license!

Table of Contents

  1. Installation & Update
  2. Usage
  3. Options
  4. Help & Improve
  5. Version History

Installation & Update

  1. Download Panel Bar
  2. Copy the whole folder to site/plugins/panel-bar

Usage

Include in your site/snippets/footer.php right before the </body> tag:

<?php echo panelbar::show(); ?>

Or with the following if you want the panel bar hidden on load:

<?php echo panelbar::hide(); ?>

You can toggle the visibility of the panel bar on the right side, but only if your website already loads jQuery. If not, panel bar will simply hide the toggle switch and display the panel bar always.

Options

Output CSS / JS separately

If you want to output the CSS and/or JS not with the panel bar, but separately e.g. in the <head> section, you first have to use (first parameter is true to get all default elements):

<?php echo panelbar::show($elements = true, $css = false, $js = false); ?>

Then you can add the following code where you want to output the CSS/JS:

<?php echo panelbar::css(); ?>
<?php echo panelbar::js(); ?>

Enhanced JS

If you have jQuery already loaded, Panel Bar can do some enhanced features through javascript. For them you have to set the following config:

c::set('panelbar.enhancedJS', true);

So far, this enables you to toggle pages' visibility right from the panel bar without being redirected to the panel.

Custom elements

Panel Bar is ready to include custom elements. Those should be set as config option:

c::set('panelbar.elements', array());

This option overrides all default elements. You can either include them by naming them:

c::set('panelbar.elements', array(
  'panel', 
  'edit', 
  'toggle', 
  'languages', 
  'logout', 
  'user'
));

Or you can merge the custom array with all default elements:

c::set('panelbar.elements', a::merge(array(
  'custom1',
  'custom 2'
), panelbar::defaults()));

You can also pass an array with all elements as first parameter when calling panelbar::show().

For custom elements you can either pass the HTML directly in the array or use the name of a callable function in the array which then returns the HTML code.

Moreover, there are currently two helpers available to create elements:

Link elements

panelbar::link(array(
  'id'     => 'panel',
  'icon'   => 'cogs',
  'url'    => site()->url().'/panel',
  'label'  => 'Panel'
  'mobile' => 'icon',
));

Dropdown elements

panelbar::dropdown(array(
  'id'    => 'lang',
  'icon'  => 'flag',
  'label' => 'Language',
  'items' => array(
               0 => array(
                     'url'   => …,
                     'label' => …
                    ),
               1 => array(
                     'url'   => …,
                     'label' => …
                    ),
               …
             ),
  'mobile' => 'label',
));

Example

c::set('panelbar.elements', array(
  'panel', 
  'edit',
  'custom-link' => panelbar::link(array(
                    'id'   => 'mum',
                    'icon' => 'heart',
                    'url'  => 'http://mydomain.com/pictureofmum.jpg',
                    'text' => 'Mum'
                  )),
  'custom-dropdown' => 'dropitpanelbar',
  'logout', 
));

function dropitpanelbar() {
  return panelbar::dropdown(array(
    'id'    => 'songs',
    'icon'  => 'headphones',
    'label' => 'Songs',
    'items' => array(
                 0 => array(
                       'url' => 'https://www.youtube.com/watch?v=BIp_Y28qyZc',
                       'text' => 'Como Soy'
                      ),
                 1 => array(
                       'url' => 'https://www.youtube.com/watch?v=gdby5w5rseo',
                       'text' => 'Me Gusta'
                      ),
               )
  ));
}

If you use any helpers like panelbar::link(), panelbar::dropdown() or panelbar::defaults() in the config.php, you must include the following line before using them:

kirby()->plugin('panel-bar');
``

You cannot use any of the following as name/id of your custom elements:  
`show, hide, css, js, defaults, __construct, __output, __content, __controlBtn, __switchBtn, __flipBtn, __float, __getCSS, __getJS, link, dropdown`


## Position of Panel Bar
You can switch the position of the panel bar from the top to the bottom browser window border (in your `site/config/config.php`):

```php
c::set('panelbar.position', 'bottom');

Help & Improve

If you have any suggestions for new elements or further configuration options, please let me know.

Version history

Check out the more or less complete changelog.

About

Panel Bar for Kirby 2 CMS

Resources

License

Stars

Watchers

Forks

Packages

No packages published