Jump to:

23552 Posts in 19349 Topics by 2891 members

General Questions

SilverStripe Forums » General Questions » Problem with displaying multiple content blocks

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1239 Views
  • MartinM
    Community Member
    6 Posts

    Problem with displaying multiple content blocks Link to this post


    I love to use Silverstripe for small projects. This backend is so easy to use, that none of my customers had ever any problems using it.

    But now I´m working on a bigger website with multiple content blocks. So I followed the Extending a basic site tutorial, but something doesn´t work properly.

    Since I want pages with content blocks, I made a new file under /mysite/code named BlockPage.php:


    class BlockPage extends Page {
       static $db = array(
    '2ndRowLeft' => 'HTMLText',
    '2ndRowRight' => 'HTMLText'
       static $has_one = array(
       * Additional Content Blocks
       function getCMSFields() {
    $fields = parent::getCMSFields();

    $fields->addFieldToTab('Root.Content.Main', new HTMLEditorField('2ndRowLeft'), 'Content');
    $fields->addFieldToTab('Root.Content.Main', new HTMLEditorField('2ndRowRight'), 'Content');

    return $fields;

    class BlockPage_Controller extends Page_Controller {


    Of course I ran "/dev/build"

    It works very good. I have two new editor fields, PhpMyAdmin shows the new tables and I can insert HTML into the DB (however, I don´t know how to put them AFTER "Content". Do I have to combine "addFieldToTab" with "insertAfter"? - But this is not the worst problem)

    To display this two blocks on my BlockPage-type pages I made a copy of .../templates/Layout/Page.ss, called it BlockPage.ss and inserted $2ndRowLeft and $2ndRowRight:

    <div class="typography">
       <% if Menu(2) %>
          <% include SideBar %>
          <div id="Content">
       <% end_if %>
       <% if Level(2) %>
           <% include BreadCrumbs %>
       <% end_if %>
          <div class="2ndRowLeft">$2ndRowLeft</div>
          <div class="2ndRowRight">$2ndRowRight</div>
       <% if Menu(2) %>
       <% end_if %>

    But Silverstripe doesn´t display the HTML I inserted using my new editor fields. All I can see on the page are the variables "$2ndRowLeft" and "$2ndRowRight".

    Did I miss anything?

    /edit: Oh yes, I flushed it ;)

  • MartinM
    Community Member
    6 Posts

    Re: Problem with displaying multiple content blocks Link to this post

    OK, I think I found it.

    It seems that SS had a problem with my "$2ndRow..." variables. Changed everything to "$SecondRow..." and it works.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.