7921 Posts in 1359 Topics by 933 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Specific content in Pages
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 186 Views |
-
Specific content in Pages

6 December 2011 at 11:00pm Last edited: 7 December 2011 12:20am
Hi, I'd like to insert some boxes in homepage with a image and text. So in Page.php I set:
<?php
class Page extends SiteTree {static $db = array(
'Date' => 'Date',
'Author' => 'Text'
);
static $has_one = array(
'TeaserText' => 'Content',
'Picture' => 'Image'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Box', new HtmlEditorField("TeaserText","Text"));
$fields->addFieldToTab('Root.Content.Box', new ImageField('Picture'));
$fields->addFieldToTab('Root.Content.Main', new textField('Author'));
$fields->addFieldToTab('Root.Content.Main', new textField('Date'));
return $fields;
}
}In Admin I see "Text" as editor and " Picture" as image. If I insert a new image and refresh the page in frontend the image appears but when I insert text or other in the editor I can't save anything.
I'd like to insert in admin text with editor to see in the pages text and image in specific boxes but SS doesn't allow me to save what I write in the editor.
How can I do?thanks
-
Re: Specific content in Pages

7 December 2011 at 1:44am
Hi!
You have an error here:
'TeaserText' => 'Content',
Reference: http://doc.silverstripe.org/sapphire/en/topics/data-types
-
Re: Specific content in Pages

7 December 2011 at 3:01am
Hi Juanitou,
thanks for your reply.
I tried to understand where is the problem you highlighted but I really found it.
I tried to set
'TeaserText' => 'HTMLText',but it dosen't work.
problably I'm PHP beginnerCould you explain me where is the issue?
thanks -
Re: Specific content in Pages

7 December 2011 at 4:25am
It doesn't belong in your has_one array. It should be in $db.
--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com
| 186 Views | ||
|
Page:
1
|
Go to Top |

