@swaiba - So I've decided to use the model admin for my testimonials. I have most of it working. I'm just getting a little bit stuck on the categories/tags. I would like to create and manage these via the model admin instead of using the tags module.
Here is what I have so far:
MyTestimonialAdmin.php
<?php
class MyTestimonialAdmin extends ModelAdmin {
public static $managed_models = array(
'Testimonial',
'Category'
);
static $url_segment = 'testimonials';
static $menu_title = 'My Testimonial Admin';
}
?>
Testimonial.php
<?php
class Testimonial extends DataObject {
static $db = array(
'Name' => 'Varchar',
'Quote' => 'Text',
'Signature' => 'Text'
);
static $many_many = array(
'Categories' => 'Category'
);
static $searchable_fields = array(
'Name',
'Quote',
'Signature'
);
static $summary_fields = array(
'Name',
'Quote',
'Signature'
);
}
?>
Category.php
<?php
class Category extends DataObject {
static $db = array(
'Title' => 'Text'
);
static $belongs_many_many = array(
'Testimonials' => 'Testimonial',
);
}
?>
A category can have many testimonials and a testimonial can have many categories so I went the many_many approach. I'm not sure if this is right.
Looking at the admin interface I can easily add categories (in general). But if I add a testimonial and click to the "Categories" tab it does not show me my existing categories. I'd like to be able to check the categories that correspond with the testimonial.
Any suggestions you have would be great. Thanks!