There was a problem loading the comments.

How to setup a customized layout for static pages only?

Support Portal  »  Knowledgebase (FAQ)  »  Viewing Article

  Print
Editions: all
Versions: all


In this HowTo we will decorate the static pages in VIMP with a customized layout. For example, it is possible to remove the right column with its user menu, search form etc. with a custom layout.

If you´re new to symfony and/or templating with VIMP, you´ll find an interesting article "Inside the View Layer" within the free symfony doku "A Gentle Introduction to symfony" at
http://www.symfony-project.org/gentle-introduction/1_4/en/07-Inside-the-View-Layer.

We use the default template here. But it´s a good idea to always work with a template copy.

The file templates/default/frontend/layout.php contains the HTML code that defines the layout of all pages of the application. We create a copy:

cp templates/default/templates/frontend/layout.php templates/default/templates/frontend/pages.php


Then we have to tell the template about the new layout. We edit line 6 in templates/default/template.yml as follows:

layouts:        {default: layout.php, media: media.php, pages: pages.php}


Two layouts already existed: "default" and "media". Now we have added a third layout "pages".

Next we modify the action that is responsible for displaying the pages, so that it uses our new pages.php.

The corresponding action method is called executeView() and stored in the base class of the module "webcontent" of the application "frontend":

apps/frontend/modules/webcontent/actions/base/BaseWebcontentActions.class.php

As the base class will be overwritten in case of an update, we extend the base class and its method executeView(). symfony already offers the needed class in

apps/frontend/modules/webcontent/actions/actions.class.php.

With the extended method the file should look like this:

<?php
class webcontentActions extends BaseWebcontentActions
{
  public function executeView(){
    parent::executeView();
    $this->setLayout(stTemplates::getLayout('pages'));
  }
}


Now, if you open a static page in your browser, it will already be decorated by the pages.php. But as we just copied the layout nothing has changed apparently.

To actually change the layout you have to adjust the file templates/default/templates/frontend/pages.php.

The content of the pages will be formatted by a separate template file: at templates/default/templates/frontend/webcontent/_contentBox.php.

But be careful with changing the _contentBox.php. This component is used in other sections, too. So changes will affect all occurrences.


Share via

Related Articles

© VIMP GmbH