Hi
i need to Model Admin for some other modules I am trying to get to run but I can't work out where to download it from. Can someone help?
Thanks
MM
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hi
i need to Model Admin for some other modules I am trying to get to run but I can't work out where to download it from. Can someone help?
Thanks
MM
ModelAdmin is built into SS 2.3.1, you don't need to download anything.
You just need to create your file that sets it up for your required data objects and adds a link to it in the CMS admin
Hey rbquirke
Thanks for the quick response. When you say you need to create a file that sets it up. What sort of file are we talking? Do you know of any documentaition which walks through set-up?
Thanks
MM
This doc covers it pretty well:
http://doc.silverstripe.com/doku.php?id=modeladmin
I also have a blog post here with a run down on some gotchas and links to a presentation on it:
http://www.cuplaweb.com/2009/03/trying-modeladmin-on-for-size/
That should get you started!
Hey rbquirke
I followed the documentation you suggested but obviously not correctly as I get the following message when I try to flush the database
Uncaught exception 'ReflectionException' with message 'Class MyCatalogAdmin does not exist' in /var/www/html/SilverStripe/cms/code/CMSMenu.php:221 Stack trace: #0 /var/www/html/SilverStripe/cms/code/CMSMenu.php(221): ReflectionClass->__construct('MyCatalogAdmin') #1 /var/www/html/SilverStripe/cms/code/CMSMenu.php(19): CMSMenu::get_cms_classes() #2 /var/www/html/SilverStripe/cms/_config.php(19): CMSMenu::populate_menu() #3 /tmp/silverstripe-cache-var-www-html-SilverStripe/manifest-main(5921): require_once('/var/www/html/S...') #4 /var/www/html/SilverStripe/sapphire/core/ManifestBuilder.php(70): require_once('/tmp/silverstri...') #5 /var/www/html/SilverStripe/sapphire/core/Core.php(165): ManifestBuilder::include_manifest() #6 /var/www/html/SilverStripe/sapphire/main.php(58): require_once('/var/www/html/S...') #7 {main} thrown in /var/www/html/SilverStripe/cms/code/CMSMenu.php on line 221
I am using the example code just cut and pasted.
<?php
class MyCatalogAdmin extends ModelAdmin {
protected static $managed_models = array(
'Product',
'Category'
);
static $url_segment = 'products'; // will be linked as /admin/products
static $menu_title = 'My Product Admin';
}
class Product extends DataObject {
static $db = array(
'Name' => 'Varchar',
'ProductCode' => 'Varchar',
'Description' => 'Text',
'Price' => 'Currency'
);
static $has_one = array(
'Category' => 'Category'
);
static $searchable_fields = array(
'Name',
'ProductCode'
);
}
class Category extends DataObject {
static $db = array(
'Title' => 'Text'
);
}
Any ideas what I am doing wrong? I
Thanks as always
MM
That embarrassing ... had named the file MyCatalog not MyCatalogAdmin!
MM