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.

General Questions /

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

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

Best solution for layout


Go to End


4 Posts   1136 Views

Avatar
sca123

Community Member, 61 Posts

11 July 2009 at 12:44am

In the attached example, you will see that I have a number of 'title boxes' that have a title, image, text, and link. I would like to be able to add/edit/delete these through Silverstripe - so what is the best way to set this up? Could you use the DataObjects module??

Some assistance would be appreciated both on the backend and frontend side of how this would work.

Thanks

Avatar
_Vince

Community Member, 165 Posts

11 July 2009 at 1:58am

Edited: 11/07/2009 2:01am

I have something like that on some pages. I basically define all that in the CMS

class MyPage extends Page {

public static $db = array(
'SideBar_Img_Comment' => 'Text'
);

public static $has_one = array(
'SideBar_Img' => 'Image',
'SideBar_Link' => 'SiteTree'
);

function getCMSFields(){

$fields = parent::getCMSFields();

$fields->addFieldToTab("Root.Content.LeftHandSideBarContent", new FieldGroup(
new TreeDropdownField("SideBar_LinkID",
"<b>SideBar Image 1</b><br />Select the page to link to and then choose the image to display",
"SiteTree"),
new ImageField('SideBar_ImgID','')));
$fields->addFieldToTab("Root.Content.LeftHandSideBarContent", new TextField('SideBar_Img_Comment', "Image Caption"));

.
.
.

return $fields;

}

After which I just place $ShowCase1_Link_ID (and so on) in the template.

Is that any help?

Avatar
bummzack

Community Member, 904 Posts

11 July 2009 at 2:34am

DataObjectManager would definitely be appropriate here.
Just create a custom DataObject class with Title, Image and Text field (maybe together with a link to a page of yours). In the template you would simply loop/output all the DataObjects.
Should be a straight forward thing to do. You'll find the dataobjectmanager documentation here: http://doc.silverstripe.com/doku.php?id=modules:dataobjectmanager

Avatar
AdamJ

Community Member, 145 Posts

11 July 2009 at 7:09pm

I actually wrote a little extension that I use in-house that is basically templated articles. I have a data-object manager that attaches articles to a page (with title, subtitle, image, content and a couple miscellanious fields), and then also a dropdown list of templates. These templates are added to the template directory in the filesystem for SS, and are defined in a modeladmin interface.

This basically allows me to have a list of articles on a single page (and an article here could be simply a small heading, some copy and an image) and then give each of those articles a different template, and the extension takes care of the rest.