Documentation 2.x and 3.x

Global sidebar

Read this if you want your sidebar to be the same in all pages.

Since ImpressPages 3.1 there is a better solutions called static blocks.

Why it is so complicated?

This is a temporary way of doing that while ImpressPages CMS does not support static / global blocks natively.

What are the steps?

1. Create new zone with name 'static'. Read here how to create new zone.

2. Add one page to that zone in Menu Management. Press right mouse on it, 'edit' and add some content to the sidebar.

3. Open ip_themes/lt_pagan/main.php and replace the line: $site->generateBlock('side'); with this code:

<?php
    $staticZoneName = 'static';
    if ($site->managementState()) {
        if ($site->getCurrentZone()->getName() == $staticZoneName) {
            echo $site->generateBlock('side');
        }
    } else {
        //print block without administration tools
        $hiddenZoneElements = $site->getZone($staticZoneName)->getElements();
        $firstElement = reset($hiddenZoneElements);
        if ($firstElement) {
            $publishedRevision = \Ip\Revision::getPublishedRevision($staticZoneName, $firstElement->getId());
            echo \Modules\standard\content_management\Model::generateBlock('side', $publishedRevision['revisionId'], $site->managementState());
        }
    }
?>

That's all. To edit sidebar, go  to that one created page and edit (don't forget to publish your changes). Published changes will immediately appear on all pages on the website.

Please note that the sidebar will be invisible in administration mode.

Comments (5)

Mangirdas

Mangirdas

Those who have installed this code before 2012-05-28, please update the code. New code fixes widget deletion issue.

Povilas Poderskis

Povilas Poderskis

I got my hands a bit dirty here and changed impresspages code (really quick solution):

Site class:

public function generateBlock($blockName, $homeRevision=false) {

<...>
if($homeRevision)
$revision = $this->getHomeRevision();
else
$revision = $this->getRevision();
<...>
}

<...>

public function getHomeRevision() {
//todo cache revision
$revision = null;
if ($this->managementState()){
$homeZone=$this->getZone('home');
$currentElement=current($homeZone->getElements());
$revision = \Ip\Revision::getLastRevision('home', $currentElement->getId());
} else {
require_once(BASE_DIR.MODULE_DIR.'standard/content_management/model.php');
$homeZone=$this->getZone('home');
$currentElement=current($homeZone->getElements());
if ($currentElement) {
$revision = \Ip\Revision::getPublishedRevision('home', $currentElement->getId());
}

}
return $revision;
}

And then you can call it like this: <?php echo $site->generateBlock('footer_6', true); ?>

YAY :)

P.S. Since I'm posting here the first time: really great work guys, awesome CMS!

Marc Roth

Marc Roth

Damn cool snippet Mr. Poderskis!

Thanks and greetings

Marc

Eugene

Eugene

Hi Mangirdas,

What do you think of Povilas Poderskis code above, is it a better solution?

Mangirdas

Mangirdas

I didn't try it. I hope it works well. There is one annoying problem with that solution: your website will be broken after update, unless you redo the same change after each update.

Write a comment

You must be logged in to comment.