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.
We use the Ocean template here. But it´s a good idea to always work with a template copy.
The file templates/ocean/frontend/layout.php contains the HTML code that defines the layout of all pages of the application. We create a copy:
cp templates/ocean/templates/frontend/layout.php templates/ocean/templates/frontend/pages.php
Then we have to tell the template about the new layout. We edit line 6 in templates/ocean/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/ocean/templates/frontend/pages.php.
The content of the pages will be formatted by a separate template file: at templates/ocean/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.