3064 Posts in 865 Topics by 647 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1427 Views |
-
Adding ImageField to CompositeField

27 February 2010 at 3:10am
Hello,
I'm trying to have a two column layout where there would be editable title, editable HTMLText content and also a possibility to add an one image.This is the way I'm trying to do:
<?php
/**
* Defines the ArticlePage page type
*/
class HomePage extends Page {
static $db = array('ContentColumns' => 'HTMLText'
);
static $has_one = array(
);
function getCMSFields() {
$fields = parent::getCMSFields();
$multiColumnField = new CompositeField(
new CompositeField(
new TextField('Header1', 'Title'),
new HTMLEditorField('Content1', 'Content'),
new ImageField('ColumnImage1', 'Image')
),
new CompositeField(
new TextField('Header2', 'Title'),
new HTMLEditorField('Content2', 'Content'),
new ImageField('ColumnImage2', 'Image')
)
);
$multiColumnField->setColumnCount(2);
$fields->addFieldToTab('Root.Content.Main', $multiColumnField, 'Content');
return $fields;
}}
class HomePage_Controller extends Page_Controller {
}?>
When I try to upload an image, it just doesn't show up. Could it be that the data type I'm trying to set is HTMLText? Any suggestions?
Thank You in advance!
-
Re: Adding ImageField to CompositeField

27 February 2010 at 10:18am
I'm not sure if a composite field will do what you're looking for, but I've never used it.
What I can see is that you haven't defined DataBase fields and relations for any of your content. You need to write Header 1, Content1, ColumnImage1, Header2, Content2, and ColumnImage2 somewhere.
static $db = array ('header1' => 'Text', 'Content1' => 'HTMLText','header2' => 'Text', 'Content2' => 'HTMLText');
static $has_one = array ('Image' => "Image');And I should warn you the I think the CMS still only supports one Image Object per page.
| 1427 Views | ||
|
Page:
1
|
Go to Top |


