niceScroll doesn’t play nice

Whilst working on a Pimcore site, I had this irritating problem with my wysiwig editors, in that if you pressed space, instead of typing a space, it scrolled the page. I knew it must be some javascript library or other included in my template, and it turns out that the culprit was niceScroll (

Found some funny forum posts, some angry guy sarcastically saying, you know, space, that separates words?

Anyway, there’s an option to disable space bar scrolling (which in my opinion should be disabled by default). Anyway, to sort it, just feed in the spacebarenabled: false option:

    function initNice() 
        if($(window).innerWidth() <= 960) 

Getting Started with Pimcore

I’ve only just started using Pimcore, but of all the CMS’es out there, this looks the best. Anyway, in the admin panel, you can create new pages etc. As the developer, we can create the templates and views, but restrict to just the editable areas for standard cms users. These editable areas are called areablocks.

For instance, in my homepage.phtml, I have the following:

<?= $this->areablock('some-id-or-other'); ?>

Once there is an areablock on a view, when you are in the admin panel, you can select an area block from the collapsible menu and literally just drag it into place, and start editing.

Customised Area files go in the website/views/areas folder. I’m making a Carousel, so in website/views/areas, I created a gallery-carousel folder, and inside that I created a view.phtml file (or .php, depending on your pimcore prefs), and a area.xml:

<?xml version="1.0"?>
<zend-config xmlns:zf="">
    <name>Slider (Tabs/Text)</name>
<section class="area-tabbed-slider-text">

    <?php if($this->editmode) { ?>
        <div class="alert alert-info">
            How many tabs you want to show?

                // prepare the store
                $selectStore = [];
                for($i=2; $i<6; $i++) {
                    $selectStore[] = [$i, $i];
            <?= $this->select("slides",[
                "store" => $selectStore,
                "reload" => true,
                "width" => 60
            ]); ?>
    <?php } ?>

        $id = "tabbed-slider-" . uniqid();
        $slides = 2; // default value
            $slides = (int) $this->select("slides")->getData();
    <div id="<?= $id ?>" class="tabbed-slider carousel slide">
        <div class="carousel-inner">
            <?php for($i=0; $i<$slides; $i++) { ?>
                <div class="item <?= ($i==0 ? "active" : "") ?> item-<?= $i ?> <?= $id . "-" . $i ?>">
                    <?php if(!$this->image("image_" . $i)->isEmpty() || $this->editmode) { ?>
                        <?= $this->image("image_" . $i, [
                            "dropClass" => $id . "-" . $i,
                            "thumbnail" => ""
                        ]); ?>
                    <?php } ?>
                    <div class="carousel-caption">
                        <h1><?= $this->input("headline_" . $i) ?></h1>
                        <p><?= $this->textarea("description_" . $i, ["nl2br" => true]) ?></p>
            <?php } ?>
        <!-- End Carousel Inner -->
        <ul class="nav nav-pills nav-justified">
            <?php for($i=0; $i<$slides; $i++) { ?>
                <li data-target="#<?= $id ?>" data-slide-to="<?= $i ?>" class="<?= ($i==0 ? "active" : "") ?> item-<?= $i ?>">
                    <a href="#">
                        <?= $this->input("pill-title_" . $i) ?>
                        <small><?= $this->input("pill-small_" . $i) ?></small>
            <?php } ?>


The customised area blocks must be enabled before they will appear in Pimcore. Click on Extras -> Extensions in the Admin section, and you will see each folder you have added. Click the icon to enable/disable the area. Now if you refresh your page with the $this->areablock(…) code, you should see your customised area available to use!

Last thing! Pimcore has all manner of caching going on! Go into Settings > Cache in order to clear it and see your changes!

Custom Navigation in Pimcore

Pimcore looks to be a great CMS! I haven’t played around with it much but if you are a fan of Zend Framework 1 then you’ll be right at home using it!

Right now, I’m designing the front end for a small promotional site that requires a CMS admin panel etc, and I’m rendering a customised Navigation view, in order to get the Bootstrap classes that I want.

Pimcore allows you to run multiple sites from the one system. So first we put a check in our layout.phtml :

$navStartNode = $this->document->getProperty("navigationRoot");
    if(!$navStartNode instanceof Document_Page) 
            $site = Site::getCurrentSite();
            $navStartNode = $site->getRootDocument();
            $navStartNode = Document::getById(1);

The root site always has Document ID 1. In the Pimcore admin panel, you right click and add a new page, then right click and you can tell it to use that page as an actual site, so you can add as many as you like!

In the layout.phtml (or view partial like header.phtml), I have the following:

<div class="navbar-collapse collapse">
        $navigation = $this->pimcoreNavigation()->getNavigation($this->document, $navStartNode);;
        echo $this->navigation()->menu()->renderPartial($navigation, 'elements/theme-nav.phtml', array(
                "maxDepth" => 1,
                "ulClass" => "nav navbar-nav"

Pimcore checks in the views folder for the partial (elements/theme-nav.phtml in my example). In my project the views folder is located in /website/views/scripts, so create an elements folder, and create theme-nav.phtml:

<ul class="nav navbar-nav"  data-0="margin-top:20px;" data-300="margin-top:5px;">
    foreach ($this->container as $page) 
        echo '<li>'.$this->navigation()->menu()->htmlify($page).'</li>';

And that’s it! Your Navigation is now rendered in the way we want!

PHP CLI commands in Debian

This problem was infuriating. After having upgraded my Vagrant Box to run PHP 5.6, I was looking forward to trying out phpdbg, the new built in debugger that ships with PHP 5.6.

It turns out that Debian use their own moronic naming system for their PHP package commands. I was typing in phpdbg into the shell, and all I got in return was ‘command not found’.

I tried sudo apt-get install php5-phpdbg, yet it told me that it was already the latest version!

I eventually found it in the /usr/bin folder, under the name php5dbg. Why?

For reference, you can run this command to help find it: (if dpkg is installed)

dpkg -L <pkgname> | grep '/bin/'

What a waste of time, I hope this helps someone.

Upgrading a PuPHPet Vagrant Boxes’ PHP to 5.6

This is remarkably simple! First, BACK UP YOUR DB.

Backed up? Good. You dont need to back your web files up if they are being mounted from a shared folder.

Open your puPHPet config.yml, scroll down to the php section, and change version from ’55’ to ’56’, and save it.

Next, type vagrant destroy, to remove the old stuff, and then vagrant up, which will re-initialise the server with your shiny new PHP version!

Injecting Closures into your Classes

I wanted to reuse a class of mine, which generated a <ul> with links, only this time I wanted to alter the link text using a custom function (closure) in the constructor.

<?= $this->generateUl($existing_arg1, $existing_arg2, function($args){ //do stuff } ); ?>

Inside the class constructor, I set the following:

public function __construct($existing_arg1, $existing_arg2, Callable $closure = null)
    $this->closure = $closure;

And here’s the wee catch: You can’t call it like a normal method, $this->closure($args); You need to assign it to a standard variable for whatever reason.

     *  @param ESOS_Entity_Org $org
     *  @return string
    private Function generateLinkText(ESOS_Entity_Organisation $org)
            // This is my default functionality
            return $org->getName();
        // There are two ways of doing this next bit:
        // $this->closure($args); won't work but $closure($args) will!
        // $closure = $this->closure; 
        // return $closure($org);

                // Here's the better way:
                return call_user_func($this->closure,$org);

Doing this has made me realise just how awesome Callables can be, you could inject in all manner of functionality into a class! Play around with it!