ModelAdmin in SilverStripe 2.3

  • 10,156 views
Uploaded on

SHDH Wellington March 2009 (http://shdh.co.nz)

SHDH Wellington March 2009 (http://shdh.co.nz)

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • @chillu : No error message, but no output similar to your slide 26.

    Where would you call the function Page->HostingTypes() ?

    Can you insert this function call using the CMS administration tools ?
    Are you sure you want to
    Your message goes here
  • @Brice21: Do you get any error messages? The example code has some output on 'our hosting deals' on slide 26. I didn't include any template logic, just a custom getter in Page->HostingTypes() - so you'll have to generate this output yourself through <% control HostingTypes %> etc.
    Are you sure you want to
    Your message goes here
  • Great tutorial, I run version 2.3 with your MyCRM demo and I can't get anything to show on the public site.
    Are you sure you want to
    Your message goes here
  • great slideshow... thanks for sharing
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
10,156
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
166
Comments
4
Likes
9

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

  • Talk briefly about the CMS.


























Transcript

  • 1. ModelAdmin SilverStripe’s great new tool for building CRMs (and other things) Monday, March 2, 2009
  • 2. We develop a CMS Monday, March 2, 2009
  • 3. We do other stu too! • Most of our sites include a CMS • But also: CRM, event management, e-commerce, internal business systems • The CMS paradigm doesn’t fit all of these Monday, March 2, 2009
  • 4. Let’s build a CRM! • We’ve made CRMs for SilverStripe ... several, in fact • Each time we had a “CRM” customer, it seemed that they wanted something dierent Monday, March 2, 2009
  • 5. Flexible Data, Fixed UI • Clients are very specific about data and business logic • But not about user interface - as long as it’s good, they’re happy • SilverStripe CMS exploits this by making it easy to create new Page Types with custom fields Monday, March 2, 2009
  • 6. From CMS to DMS • Can we apply this concept to CRM? • Don’t just manage Content • Manage any kind of Data Monday, March 2, 2009
  • 7. ModelAdmin • Data Management built into SilverStripe • ModelAdmin gives you a CRUD interface around any data: Search, Results, Detail • Same building blocks as CMS interface Monday, March 2, 2009
  • 8. ModelAdmin • Search on fields linked by relations • Detail record gives you a scaolded interface for editing all relations Monday, March 2, 2009
  • 9. Monday, March 2, 2009
  • 10. Monday, March 2, 2009
  • 11. Monday, March 2, 2009
  • 12. Code Demo Monday, March 2, 2009
  • 13. Random example: A small webhosting company with products, customers and contracts * Web2.0ified by http:// creatr.cc Monday, March 2, 2009
  • 14. Our Datamodel HostingContrac Customer HostingType t has_many has_one Monday, March 2, 2009
  • 15. HostingType <?php class HostingType extends DataObject { static $db = array( 'Title' => 'Text', 'Description' => 'Text', 'Price' => 'Float', ); static $has_many = array( 'HostingContracts' => 'HostingContract', ); } ?> mysite/code/HostingType.php Monday, March 2, 2009
  • 16. HostingType Monday, March 2, 2009
  • 17. HostingContract <?php class HostingContract extends DataObject { static $db = array( 'ContractNumber' => 'Varchar', 'StartDate' => 'Date', 'EndDate' => 'Date' ); static $has_one = array( 'Customer' => 'Customer', 'HostingType' => 'HostingType', ); } ?> mysite/code/HostingContract.php Monday, March 2, 2009
  • 18. HostingContract Monday, March 2, 2009
  • 19. Customer <?php class Customer extends Member { static $db = array( 'CustomerType' => quot;Enum('Private,Business','Private')quot; ); static $has_one = array( 'Avatar' => 'Image', ); static $has_many = array( 'HostingContracts' => 'HostingContract' ); } ?> mysite/code/Customer.php Monday, March 2, 2009
  • 20. Monday, March 2, 2009
  • 21. MyCRMAdmin <?php class MyCRMAdmin extends ModelAdmin { protected static $managed_models = array( 'Customer', 'HostingContract', 'HostingType' ); static $url_segment = 'mycrm'; // will be linked as /admin/mycrm static $menu_title = 'My CRM'; } ?> mysite/code/MyCRMAdmin.php Monday, March 2, 2009
  • 22. Some tweaking... Monday, March 2, 2009
  • 23. Summary Fields <?php class Customer extends Member { // ... static $summary_fields = array( 'FirstName', 'Surname', 'CustomerType' ); } ?> Monday, March 2, 2009
  • 24. Searchable Fields <?php class Customer extends Member { // ... static $searchable_fields = array( 'FirstName', 'Surname', 'HostingContracts.ContractNumber' ); } ?> Monday, March 2, 2009
  • 25. getCMSFields() <?php class Customer extends Member { // ... function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Locale'); return $fields; } } ?> Monday, March 2, 2009
  • 26. Using Data on Monday, March 2, 2009
  • 27. SilverStripe 2.4 and beyond • New data mapper • Thinner, reusable controllers • “Intelligent data” Monday, March 2, 2009
  • 28. Thank you Download this talk at: http://www.slideshare.net/chillu/modeladmin-in-silverstripe-23 Code (requires SilverStripe 2.3+) http://silverstripe.org/assets/presentations/2009-02-28- modeladminpresentationmysite.zip Ingo Schommer, SilverStripe Ltd., ingo@silverstripe.com License: http://creativecommons.org/licenses/by-nc/3.0/nz/ Monday, March 2, 2009