Hello,
I'm very new to SS. In fact, I don't know if I'm posting on right Forum:]
I'm trying to create Page Categories with Images. Right now I have Categories class:
I was trying to add Image Field, but it's not worked.
<?php
class Category extends DataObject {
static $db = array(
'Title' => 'Varchar'
// 'Title2' => 'Varchar'
);
static $has_one = array(
// 'Photo' => 'Image'
);
static $field_types = array(
'Title' => 'TextField',
// 'Photo' => 'ImageField'
// 'Photo' => 'ImageField'
);
static $field_names = array(
'Title' => 'Category Name',
// 'Photo' => 'Category Name 2',
// 'Photo' => 'Category Icon'
);
static $belongs_many_many = array(
'Recipes' => 'Recipe'
);
}
?>
and then
<?php
class Page extends SiteTree {
// ..
function getCMSFields() {
$fields = parent::getCMSFields();
$categoryTable = new TableField('Categories', 'Category', Category::$field_names, Category::$field_types);
$categoryTable->setPermissions(array('add', 'edit', 'delete'));
$fields->addFieldToTab('Root.Content.Categories', $categoryTable);
return $fields;
}
// ..
}
?>
without Image it works perfect, but I need add Image icon for each category.
Can same one help me?
Sorry for my bad english, it's not my native language.