Hello
I'm trying to do the following using model admin :
I have categories who have sub categorie (works) and each works has several file (images) attached to them so it looks like this.
CATEGORY 1
Work 1 > multiple file attachment
Work 2 > multiple file attachment
To do so I used the example given in the modeladmin wich gives me :
WorkManager.php
<?php
class WorkManager extends ModelAdmin {
public static $managed_models = array(
'Work',
'Category'
);
static $url_segment = 'works';
static $menu_title = 'WorksManager';
}
Work.php
<?php
class Work extends DataObject {
static $db = array(
'Name' => 'Varchar'
);
static $has_one = array(
'Category' => 'Category'
);
static $searchable_fields = array(
'Name'
);
}
Category.php
<?php
class Category extends DataObject {
static $db = array(
'Title' => 'Text'
);
}
?>
this part works fine and I understand how it works.
Then I get lost, I had set up in previous project a Ressource page based on some other example :
Ressource.php
<?php
class Resource extends DataObject
{
static $db = array (
'Name' => 'Text',
);
static $has_one = array (
'Attachment' => 'File',
'ResourcePage' => 'ResourcePage'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name'),
new FileIFrameField('Attachment')
);
}
}
?>
RessourcePage.php
<?php
class ResourcePage extends Page
{
static $has_many = array (
'Resources' => 'Resource'
);
public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new FileDataObjectManager(
$this, /
'Resources',
'Resource',
'Attachment',
array(
'Name' => 'Name',
'Description' => 'Description'
),
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
);
$f->addFieldToTab("Root.Content.Resources", $manager);
return $f;
}
}
class ResourcePage_Controller extends Page_Controller {
}
}
That also was working fine
Could anybody show me how to combine those 2 approach.
Right now I only want to load datas, my next step will be to create a CategoryPage but I'm trying to do this step by step with a simple example.
Thanks for any help
T