Hello,
My question is:
How to create homepages (as in the demo):
- Content
- Left box text
- Left Image
- Middle text box
- Middle Image
- Right text box
- Image Right
Thank you again
Sincerely,
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
Hello,
My question is:
How to create homepages (as in the demo):
- Content
- Left box text
- Left Image
- Middle text box
- Middle Image
- Right text box
- Image Right
Thank you again
Sincerely,
Have a read of tutorial 2. This covers how to add fields to pages. In the case of the demo it looks something like
<?php
class HomePage extends Page {
static $db = array(
"LeftBoxTxt" => "HTMLText",
"MiddleBoxTxt" => "HTMLText",
"RightBoxTxt" => "HTMLText"
);
static $has_one = array(
'LeftBoxImg' => 'Image',
'MiddleBoxImg' => 'Image',
'RightBoxImg' => 'Image'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new HTMLEditorField("LeftBoxTxt","Left box text"));
$fields->addFieldToTab("Root.Content.Main", new ImageField('LeftBoxImg', 'Left Image'));
$fields->addFieldToTab("Root.Content.Main", new HTMLEditorField('MiddleBoxTxt','Middle box text'));
$fields->addFieldToTab("Root.Content.Main", new ImageField('MiddleBoxImg', 'Middle Image'));
$fields->addFieldToTab("Root.Content.Main", new HTMLEditorField('RightBoxTxt','Right box text'));
$fields->addFieldToTab("Root.Content.Main", new ImageField('RightBoxImg', 'Right Image'));
return $fields;
}
}
class HomePage_Controller extends Page_Controller {
}
But I recommend reading the 2nd SilverStripe tutorial (http://doc.silverstripe.org/sapphire/en/tutorials/2-extending-a-basic-site) to get to grips with what that code does.