Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

ModelAdmin


Go to End
Reply

17 Posts   3940 Views

Avatar
UncleCheese

15 November 2008 at 6:25am 4085 Posts

Okay, I love the idea, but I have no idea how to use it. I put this in my mysite/code/ folder:

<?php

class MyModelAdmin extends ModelAdmin
{
   protected static $managed_models = array (
      'StaffMember'
   );
   
   public function Link()
   {
      return 'admin/mymodeladmin/';
   }
}

?>

Not noticing anything new in the CMS. Did I do this right?

Avatar
UncleCheese

18 November 2008 at 4:39am 4085 Posts

Seriously? No one knows how to use this thing?

Avatar
jam13

18 November 2008 at 4:59am 121 Posts

There's precious little documentation on this that I can find. I've got as far as getting a new tab to appear in the admin panel, and it seems to have all the right controls, however clicking on "Create" just throws a js error:

processOnDemandHeaders is not defined

which seems to be jQuery related. I'm planning on debugging this further when I get the time, but I'd like to hear if anyone has actually got this to work.

Avatar
simon_w

18 November 2008 at 7:45am Forum Moderator, 474 Posts

I have three working, and will be updating the docs shortly. Assuming that the code is in MyModelAdmin.php, have you tried adding ?flush=1?

jam13, that has been fixed in [url=http://open.silverstripe.com/changeset/65843]r65843[/url] and [url=http://open.silverstripe.com/changeset/65851]r65851[/url]

Avatar
Fuzz10

18 November 2008 at 9:20pm Community Member, 787 Posts

We can't get this thing going as well. It does display the interface (the left bar) , but nothing happens when you want to use it.

Love the idea though !

Avatar
jam13

18 November 2008 at 11:33pm 121 Posts

Try checking out the lastest 2.3 branch code (not nightly builds which apparently are not being updated). I finally got this working last night after being told by simon_w that there had been a number of fixes for modeladmin in the last few days.

http://svn.silverstripe.com/open/phpinstaller/branches/2.3/

Avatar
Fuzz10

19 November 2008 at 2:07am Community Member, 787 Posts

Hi Jam,

Thanks for the tip, that helped !

Love what I'm seeing so far !

Avatar
UncleCheese

25 November 2008 at 8:24am 4085 Posts

I have no idea how you guys are getting this to work. I don't see any new tab in the CMS, and when I try to manually enter the url /admin/crm, I get a Fatal Error: Disallowed action "crm" on controller CMSMain.

Here's my code:

<?php

class MyModelAdmin extends ModelAdmin
{
   protected static $managed_models = array (
      'StaffMember'
   );
   
   
   static $url_segment = 'crm';
   static $menu_title = 'My CRM';   
}
class StaffMember extends SortableDataObject
{
   static $db = array (
      'Name' => 'Varchar(50)',
      'Title' => 'Varchar(50)',
      'Description' => 'Text'
   );
   
   static $has_one = array (
      'Photo' => 'Image',
      'AboutPage' => 'AboutPage'
   );
   
   static $searchable_fields = array (
      'Name', 'Title'
   );
   
}

?>

Go to Top