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   4091 Views

Avatar
UncleCheese

Forum Moderator, 4096 Posts

15 November 2008 at 6:25am

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

Forum Moderator, 4096 Posts

18 November 2008 at 4:39am

Seriously? No one knows how to use this thing?

Avatar
jam13

121 Posts

18 November 2008 at 4:59am

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

Forum Moderator, 474 Posts

18 November 2008 at 7:45am

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

Community Member, 787 Posts

18 November 2008 at 9:20pm

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

121 Posts

18 November 2008 at 11:33pm

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

Community Member, 787 Posts

19 November 2008 at 2:07am

Hi Jam,

Thanks for the tip, that helped !

Love what I'm seeing so far !

Avatar
UncleCheese

Forum Moderator, 4096 Posts

25 November 2008 at 8:24am

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