Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

Content blocks


Go to End


3 Posts   615 Views

Avatar
Christy

Community Member, 68 Posts

23 February 2017 at 2:51pm

I'm developing a website using bootstrap and have installed the entidi/bootstrap theme. SS 3.5.2

I have spent hours/days searching and trying content box modules and haven't found the explanation of what they do very clear. I would really appreciate any recommendations. Preferably for the ability to create reusable content eg box with heading, text and image; or 3 columns without editing mysite files.

Thanking you in advance.

Avatar
Michael J James

Community Member, 8 Posts

24 February 2017 at 10:04am

Edited: 28/02/2017 10:20pm

Hi @Christy,

I normally use https://github.com/sheadawson/silverstripe-blocks

You just extend block and add any fields you want

<?php
class ImageTextBlock extends Block {
    private static $db = array(
        'Title' => 'Varchar(255)',
        'Content' => 'HTMLText'
    );
    private static $has_one = array(
        'Image' => 'Image'
    );
}

and template

<div class="container">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
             <h3>$Title</h3>
             $Content
        </div>
        <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
             $Image
        </div>
    </div>
</div>

do a dev/build and you should have a new block called ImageTextBlock

Thanks
Michael

Avatar
Christy

Community Member, 68 Posts

24 February 2017 at 6:40pm

Thank you very much for the above, Michael.
I have been working at getting this module set up until another issue arrived!