Blocks
Blocks are areas filled with content, for example header, sidebars or footer. Blocks are used to display the same content across multiple pages, for example a menu, that should appear on all pages. You can assign multiple contents to a block, so that they will appear beneath each other.
To display a block you have to provide for two things:
- The block must be assigned to a theme. You can do this in the backend when you edit a theme.
- Each block has a token, that is used as an identifier for that block in template-files (See the chapter about themes for more information). For example, if you want to display a block with the token "sidebar-right", you would write the following to the template-file:
<?php echo $this->blocks['sidebar-right'] ?>
You can create and edit blocks in the backend under Site -> Blocks. The default package of Dubsite comes with some preconfigured blocks and themes, that you can use to get started.
Different block-content on certain pages
Sometimes it is necessary to display different content in a block, depending on the page that is requested. For example, on some pages of your website you may want to display a different menu in the block "Sidebar Right".
To achieve this, you first create a menu, that you configure to display the desired menu-items. Then you create a new block, to which you assign your new menu. After that you create a new theme, to which you assign your new block. Finally you assign this theme to the appropriate pages.
Example: Let's assume you have a website, where the right sidebar (a block with the token "sidebar-right") contains a menu on each page. On some pages you want to display a different menu on that sidebar. Do the following:
- In the backend go to Site -> Contents and click on "Create Content" to create a new menu. On the next page select the contenttype "Menu", enter a name for the menu and click "Create".
- Now you can edit your menu and configure it to display the desired menu-items. Remember to set the menu from "inactive" to "active" when you're done and save the menu.
- Then go to Site -> Blocks and create a new block with the token "sidebar-right", but with a distinctive name, e.g. "Sidebar Right 2".
- Now assign your new menu to the block: Click the name of the new block in the list to edit it, then open the box "Add Content", select the contenttype "Menu", select your new menu and click "Add".
- Go to Site -> Themes and create a copy of the theme you are currently using on your pages: Mark the checkbox beside the theme and click "Copy".
- Now edit the new Theme by clicking on it's name. In the selectbox next to the "sidebar-right"-block select the new Block "Sidebar Right 2" and save the theme.
- Finally go to Site -> Pages, select the new theme for the desired pages and click the green checkmark on top to save the changes.
Now the new menu will appear on these pages.
