Silverstripe

Silverstripe

silverstripe #silverstripe 1 1: 2 2 2 Examples 2 2 CMS / 2 2: DataExtensions 4 Examples 4 DataObject 4 DataObject 4 DataExtension 4 3: LeftAndMain 6 6 Examples 6 1. 6 6 6 6 2. HelloWorldLeftAndMain.php 6 7 7 7 3. (HelloWorldLeftAndMain_Content.ss) 8 . 8 8 4: ModelAdmin 9 Examples 9 9 UI DataObject 9 DataObject . 9 DataObject 9 searchable_fields ModelAdmin . 10 GridField 10 ModelAdmin 11 5: ORM 12 Examples 12 DataObject 12 6: 13 13 ? 13 13 Examples 13 13 13 YAML 13 13 7: 15 15 Examples 15 SilverStripe Grid 15 GridField 15 15 15 CMS 16 16 8: 17 17 Examples 17 17 AJAX 17 17 19 20 : 20 9: 22 22 Examples 22 MyClass.php 22 23 You can share this PDF with anyone you feel could benefit from it, downloaded the latest version from: silverstripe It is an unofficial and free silverstripe ebook created for educational purposes. All the content is extracted from Stack Overflow Documentation, which is written by many hardworking individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official silverstripe. The content is released under Creative Commons BY-SA, and the list of contributors to each chapter are provided in the credits section at the end of this book. Images may be copyright of their respective owners unless otherwise specified. All trademarks and registered trademarks are the property of their respective company owners. Use the content presented in this book at your own risk; it is not guaranteed to be correct nor accurate, please send your feedback and corrections to [email protected] https://riptutorial.com/ko/home 1 1: Silverstripe PHP . • BSD - . • . • . , MySQL . 3.4.0 2016-06-03 Examples SilverStripe zip . composer create-project silverstripe/installer /path/to/project 3.4.0 zip SilverStripe . SilverStripe . CMS / SilverStripe CMS CMS , . config.yml . LeftAndMain: application_name: 'My Application' application_link: 'http://www.example.com/' extra_requirements_css: - mysite/css/cms.css mysite / css / cms.css .ss-loading-screen { background: #fff; } .ss-loading-screen .loading-logo { background: transparent url('../images/my-logo-loading.png') no-repeat 50% 50%; } .cms-logo a { background: transparent url('../images/my-logo-small.png') no-repeat left center; } https://riptutorial.com/ko/home 2 : https://riptutorial.com/ko/silverstripe/topic/1771/-- https://riptutorial.com/ko/home 3 2: DataExtensions Examples DataObject DataExtension DataObject . class MyMemberExtension extends DataExtension { private static $db = [ 'HairColour' => 'Varchar' ]; } . # File: mysite/_config/app.yml Member: extensions: - MyMemberExtension HairColour Member . DataObject DataObject public . class MyMemberExtension extends DataExtension { public function getHashId() { return sha1($this->owner->ID); } } Member sha1 Member ID Member $this->owner . : $member = Member::get()->byId(123); var_dump($member->getHashId()); // string(40) "40bd001563085fc35165329ea1ff5c5ecbdbbeef" DataExtension Config . : # File: mysite/_config/config.yml Member: extensions: - MyMemberExtension https://riptutorial.com/ko/home 4 extensions "array" . # File: mysite/_config/config.yml Member: extensions: - MyMemberExtension - MyOtherMemberExtension . <?php class MyClass extends DataObject { private static $extensions = ['MyCustomExtension']; } DataExtensions : https://riptutorial.com/ko/silverstripe/topic/3519/dataextensions https://riptutorial.com/ko/home 5 3: LeftAndMain LeftAndMain API ModelAdmin . ModelAdmin LeftAndMain . Examples 1. LeftAndMain . Hello World . CMS 3.* 3.* 4.* . SS4 FQCN (Full Quality Class Name) . tl; dr . 1. /helloworld/ _config.php . SilverStripe . SilverStripe _config.php . 2. /code/ . /admin/ . 3. /helloworld/code/admin/HelloWorldLeftAndMain.php . class HelloWorldLeftAndMain extends LeftAndMain { } 4. /helloworld/templates/Includes/HelloWorldLeftAndMain.ss . /framework/ /cms/ /helloworld/ + _config.php + /code/ + /admin/ + /HelloWorldLeftAndMain.php + /templates/ + /Includes/ + /HelloWorldLeftAndMain_Content.ss 2. HelloWorldLeftAndMain.php . https://riptutorial.com/ko/home 6 class HelloWorldLeftAndMain extends LeftAndMain { } $url_segment , ( $menu_title ) private static $url_segment = 'helloworld'; private static $menu_title = 'Hello World'; . private static $menu_icon = 'helloworld/path/to/my/icon.png'; private static $url_rule = '/$Action/$ID/$OtherID'; LeftAndMain LeftAndMain init . CSS . , CMS ( : 3.* ~ 4.* . 3.* CSS 4.* 4.* ) helloworld/css/styles.css . public function init() { parent::init(); Requirements::css('helloworld/css/styles.css'); //Requirements::javascript('helloworld/javascript/script.min.js'); } Javascript Javascript . $allowed_actions Page_Controller Page_Controller . index() index() override index() . index() HelloWorldLeftAndMain_Content.ss ( ). class HelloWorldLeftAndMain extends LeftAndMain { private static $url_segment = 'helloworld'; private static $menu_title = 'Hello World'; private static $allowed_actions = array( 'some_action' ); public function init() { parent::init(); Requirements::css('helloworld/css/styles.css'); //Requirements::javascript('helloworld/javascript/script.min.js'); } https://riptutorial.com/ko/home 7 public function Hello($who=null) { if (!$who) { $who = 'World'; } return "Hello " . htmlentities($who); } } 3. (HelloWorldLeftAndMain_Content.ss) . 1. • .north • .center • .south 2. data-pjax-fragment="Content" . AJAX "Content" . <div class="cms-content center $BaseCSSClasses" data-layout-type="border" data-pjax- fragment="Content"> </div> SilverStripe . ; <% include CMSBreadcrumbs %> <% include CMSBreadcrumbs %> . CSS <div class="cms-content center $BaseCSSClasses" data-layout-type="border" data-pjax- fragment="Content"> <%-- This will add the breadcrumb that you see on every other menu item --%> <div class="cms-content-header north"> <div class="cms-content-header-info"> <% include CMSBreadcrumbs %> </div> </div> <div class="center"> <%-- Our function in HelloWorldLeftAndMain.php --%> $Hello('USER'); <%-- ^ outputs "Hello USER" --%> </div> <div class='south'> Some footer-worthy content </div> </div> /dev/build ?flush=1 ! LeftAndMain : https://riptutorial.com/ko/silverstripe/topic/8300/leftandmain https://riptutorial.com/ko/home 8 4: ModelAdmin Examples DataObject : class MyDataObject extends DataObject { private static $db = array( 'Name' => 'Varchar(255)' ); } Create-Read-Update-Delete ModelAdmin . class MyModelAdmin extends ModelAdmin { private static $mangaged_models = array( 'MyDataObject' ); private static $url_segment = 'my-model-admin'; private static $menu_title = 'My Model Admin'; private static $menu_icon = 'mysite/images/treeicons/my-model-admin.png'; private static $menu_priority = 9; } UI DataObject class MyDataObject extends DataObject { private static $singular_name = 'My Object'; private static $plural_name = 'My Objects'; ... } DataObject . class SortDataObject extends DataObject { private static $db = array( 'Name' => 'Varchar', 'SortOrder' => 'Int' ); private static $default_sort = 'SortOrder DESC'; } DataObject class MyDataObject extends DataObject { https://riptutorial.com/ko/home 9 private static $db = array( 'Name' => 'Varchar' ); private static $has_one = array( 'OtherDataObject' => 'OtherDataObject' ); private static $summary_fields = array( 'Name', 'OtherDataObject.Name' ); private static $field_labels = array( 'OtherDataObject.Name' => 'Other Data Object' ); } ModelAdmin summary_fields . field_labels field_labels field_labels . searchable_fields ModelAdmin . class MyDataObject extends DataObject { private static $db = array( 'Name' => 'Varchar' ); private static $has_one = array( 'OtherDataObject' => 'OtherDataObject' ); private static $summary_fields = array( 'Name', 'OtherDataObject.Name' ); private static $searchable_fields = array( 'Name', 'OtherDataObjectID' => array( 'title' => 'Other Data Object' ) ); } OtherDataObjectID . GridField class MyDataObject extends DataObject { ... private static $has_many = array( 'OtherDataObjects' => 'OtherDataObject' ); https://riptutorial.com/ko/home 10 function getCMSFields() { $fields = parent::getCMSFields(); if ($gridField = $fields->dataFieldByName('OtherDataObjects')) { $gridField->getConfig() ->removeComponentsByType('GridFieldExportButton'); } return $fields; } } ModelAdmin class MyAdmin extends ModelAdmin { ... function getEditForm($id = null, $fields = null) { $form = parent::getEditForm($id, $fields); if ($this->modelClass == 'MyDataObjectName') { $form->Fields() ->fieldByName($this->sanitiseClassName($this->modelClass)) ->getConfig() ->removeComponentsByType('GridFieldExportButton'); } return $form; } } ModelAdmin : https://riptutorial.com/ko/silverstripe/topic/3836/modeladmin https://riptutorial.com/ko/home 11 5: ORM Examples DataObject SilverStripe DataObject . DataObject . class Fruit extends DataObject { private static $db = ['Name' => 'Varchar']; } Fruit . $apple = Fruit::create(); $apple->Name = 'Apple'; $apple->write(); Fruit . $apple = Fruit::get()->filter('Name', 'Apple')->first(); var_dump($apple->Name); // string(5) "Apple" ORM : https://riptutorial.com/ko/silverstripe/topic/3463/orm- https://riptutorial.com/ko/home 12 6: ? SilverStripe . , API . Config dev/build cache flush ( URL ?flush ) SS_ConfigStaticManifest . SS_ConfigStaticManifest PHP YAML SS_ConfigStaticManifest . YAML private static Config . Examples Config . 1. SilverStripe private static 2. yaml (module-folder / _config / [file] .yml ) 3. PHP ( Config::inst()->update('Director', 'environment_type', 'dev') 2 . class MyDataObject extends DataObject { private static $db = array( 'Title' => 'Varchar', ); } SilverStripe ( vendor/

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    27 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us