silverstripe

Find whether an Image is used anywhere

纵饮孤独 提交于 2019-12-11 04:44:39
问题 In my SilverStripe 3.4 environment I have a bunch of different models that have an attached Image, e.g.: BlogPost has_one Image (via silverstripe/blog) Widget has_one Image (via silverstripe/widgets) MyWidget has_one Image (custom module) I want to prevent an Image e.g. ID 123 from being deleted in the CMS admin if it's used in any of the above (as examples - this should be system wide). Is there a way that I can check all models that have a related Image at once, maybe via a Image belongs

Silverstripe Menu, Submenu, and Breadcrumbs

非 Y 不嫁゛ 提交于 2019-12-11 04:29:43
问题 How do I change the default Silverstripe theme 'Simple' so that when a submenu (on the sidebar) is clicked the sidebar menu is replaced by a breadcrumb via $Breadcrumbs. Example when Menu1 is clicked, the sidebar is shown Menu1 Menu2 Menu3 Menu1 (not clickable, just a title) SubMenu1 SubMenu2 but when either SubMenu1 or SubMenu2 is clicked entire sidebar dissapears and a $Breadcrumbs is shown. Menu1 Menu2 Menu3 Menu1-->SubMenu1 $Content Therefore when Menu1 on Breadcrumb is clicked, it goes

SilverStripe Gridfield how to remove buttons

余生长醉 提交于 2019-12-11 04:16:14
问题 I have been going through the gridfield class documentation here; http://doc.silverstripe.org/framework/en/reference/grid-field Here is the code in question. While it does display a grid-field it adds a button on each columns. How would I edit this code to not display the buttons? The buttons are links to a non-existent page. Link to rendered page; http://www.silverstripe.org/assets/Uploads/Capture28.JPG public function AllPages() { $gridField = new GridField('pages', 'All pages', SiteTree:

SilverStripe 3 Filtering / Filtering Out DataObjects in a Function

断了今生、忘了曾经 提交于 2019-12-11 03:36:22
问题 I've found some examples of filtering but nothing clear enough to answer my question. I have the following function to get my grand children pages. I'm trying to count them but only if they meet certain criteria. In my case if they do not have X,Y,Z then include them in the count. In other words would like to add a list / array of arguments to the function that if ANY are true then don't include them and filter them out. For example if DealerOnly = true ignore. I thought about doing this in

Silverstripe - filter DataObject list by many many relationship

一世执手 提交于 2019-12-11 03:30:01
问题 I have an Object that extends Page ("Thing") which has a many_many relationship with a DataObject ("Tag"). class Thing extends Page { static $many_many = array( 'Tags' => 'Tag' ); } class Tag extends DataObject { static $belongs_many_many = array( 'Things' => 'Thing' ); } I have an array of Tag IDs and I want to get a list of Things that have all of these tags attached. The following should be possible... $tag_ids = array(1,2,3,4); $things = Thing::get(); $things->filter('Tags.ID', array($tag

SilverStripe. Search by date-range in ModelAdmin

淺唱寂寞╮ 提交于 2019-12-11 02:21:53
问题 I have date-property in my DataObject. How can I search by date-range in ModelAdmin? For example: "search all items where date is more than 2007-13-01 and less than 2007-17-01" or "search all items where date is between 2007-13-01 and 2007-17-01" For now I can search only with GreaterTranFilter or with LessThanFilter, but not with both. class MyObject extends DataObject { private static $db = [ "Date" => "Date", ]; private static $summary_fields = [ "Date" => "Date", ]; private static

In SilverStripe 4, how to extend an existing method when there is no Extension Hook inside the original method?

人盡茶涼 提交于 2019-12-11 00:55:47
问题 I want to override 'loginForm' method in 'LoginHandler' class. I am trying to use the code given below for that. But it is not working. LoginHandlerExtension.php <?php use SilverStripe\Core\Extension; class LoginHandlerExtension extends Extension { public function loginForm() { return 'xxxxxx'; } } app.yml SilverStripe\Security\MemberAuthenticator\LoginHandler: extensions: - LoginHandlerExtension 回答1: What would you want to override on the loginForm method? If you want it to use a different

Submit form within controller extension - SilverStripe 3.4.0

为君一笑 提交于 2019-12-10 22:33:01
问题 I'm trying to submit a form created within an controller extension. After Submitting, it throws me an error Sadly I don't know why or how to solve this, without losing the build in validation and so . I could manually change the form action to "doSectionForm", than I'll receive the forms data but have lost all the validation. Here's an excerpt of my code. <?php class SectionsPageControllerExtension extends DataExtension { private static $allowed_actions = [ 'SectionForm' ]; public function

How to define composite primary key in SilverStripe ORM/Dataobject

Deadly 提交于 2019-12-10 20:25:28
问题 SilverStripe's DataObject gives us the following to start with: ID - primary key But how do you define a composite key (primary key composed of 2 or more columns)? I've searched the documentation and can not find this information anywhere. 回答1: I'm not sure about the primary key, but you can set a unique index instead. It should give you a sort-a-like result as mentioned here. class YourDataObject extends DataObject { private static $db = [ 'MyField' => 'Varchar', 'MyOtherField' => 'Varchar'

Is it possible to run a function on a Silverstripe template variable to format output?

荒凉一梦 提交于 2019-12-10 16:13:49
问题 I've created a data model that includes a plain textarea entry field for an office address. I would like to do the equivalent of nl2br($OfficeAddr) when printing the data in my relevant Silverstripe template. As far as I can tell, their templating system does not support such functionality. Am I missing something? Any recommended workarounds? 回答1: In Silverstripe 3 this would be best achieved by creating a DataExtension class (as opposed to overriding the class). (Note: this would be possible