This is the documentation for LemonStand V1, which has been discontinued. You can learn more and upgrade your store here.

LemonStand Version 1 Has Been Discontinued

This documentation is for LemonStand Version 1. LemonStand is now offered as a cloud-based eCommerce platform.
You can try the new LemonStand and learn about upgrading here.

Using the Page Blocks Feature

The page blocks feature allows you to inject page-specific code blocks to the page layout. It is helpful, for example, when you have a page which contains a main area and a sidebar, and the sidebar should contain some page-specific data. In this case you can define the sidebar layout markup in the page layout and define a sidebar block in the page. LemonStand will inject the page sidebar content to the layout. It will simplify the page and layout code, because the page code will not contain any layout-specific markup.

To define page block please click the Head & Blocks tab on the Create/Edit Page form. Click the Add Block link to create a new block. Enter a block code, for example "sidebar". You will use this code for outputting the block in the page layout. Enter the block content (HTML/PHP) to the text area. All PHP variables generated by the page action are available in the block code. So if you were creating a page based on the shop:product action, the $product variable would be available in the page blocks code. You can define up to 5 page blocks for each page.

To output the block content on the page layout use the following call:

<? $this->render_block('sidebar')  ?>
{{ render_block('sidebar') }}

render_block() is a method of the Cms_Controller. It accepts a single parameter - the block code. If a page does not contain a block with the specified code, no error will occur.

The following layout code example outputs page header declarations and two blocks - the header and the sidebar. With this approach the page code will not contain the layout elements (in this case the DIV elements #header, #left_column and #right column). The layout markup is defined in the layout, while the page blocks output only page-specific information.

<html>
  <head>
    <title><?= h($this->page->title) ?></title>
     <? $this->render_head() ?>
  </head>
  <body>
    <div id="header"><? $this->render_block('header') ?></div>
     
    <div id="left_column">
      <? $this->render_page() ?>
    </div>
    
    <div id="right_column">
      <? $this->render_block('sidebar') ?>
    </div>
  </body>
</html>
<html>
  <head>
    <title>{{ this.page.title }}</title>
     {{ render_head() }}
  </head>
  <body>
    <div id="header">{{ render_block('header') }}</div>
     
    <div id="left_column">
      {{ render_page() }}
    </div>
    
    <div id="right_column">
      {{ render_block('sidebar') }}
    </div>
  </body>
</html>


Previous: Using the Page Head Declarations Field
Return to The Page Basics