silverstripe

Overload Enum in SilverStripe DataExtension

时光怂恿深爱的人放手 提交于 2019-12-24 00:35:54
问题 Is it possible to overload an Enum field using a DataExtension? class Order extends DataObject { private static $db=array('Status'=>"Enum('Unpaid, Paid','Unpaid')"; } class OrderExtension extends DataExtension { private static $db=array('Status'=>"Enum('Unpaid, Paid, Cancelled','Unpaid')"; //doesn't work } 回答1: I couldn't figure out how to get the augmentDatabase() method to work, but after speaking with a colleague he suggested using config.yml and this did the trick. Order: db: Status: Enum

How to use javascript in Silverstripe CMS?

ぃ、小莉子 提交于 2019-12-23 20:59:28
问题 I'm using SilverStripe 3.0 CMS, and I need to include a Google Map into the CMS. I'm following this steps, and besides it's a little bit old, the official documentation uses the same methods in the current version of SilverStripe (At least it seems to be the current version documentation). The issue is in this part of the code: Behaviour.register({ "#Form_EditForm" : { initialize : function() { this.observeMethod("PageLoaded", this.adminPageHandler); this.adminPageHandler(); },

Optional OptionsetField is SilverStripe 3.2

↘锁芯ラ 提交于 2019-12-23 17:19:09
问题 In SilverStripe 3.1.* I used some forms with OptionsetFields which are optional, so not required to make a choice. This was working well. But since i updated to SilverStripe 3.2.0 the form doesn't accept this anymore. When submit it comes with a validation message, even if I don't use validation in the whole form. See this screenshot: This is the code of the field: $ClassField = OptionsetField::create('Class', _t('General.CLASS', "Class"), array( "S" => "S", "E" => "E", "U" => "U", "R" => "R"

Strange behavior happening in Silverstripe backend?

我与影子孤独终老i 提交于 2019-12-23 17:18:45
问题 All of a sudden whenever I try to click into a page in the silverstripe backend it initially displays like this, I was running SS 3.2, when this started happening I upgraded to 3.2.1 to see if that would fix the issues but nope: Sometimes it displays this error message aswell: [User Warning] Couldn't set response type to 404 because of output on line 1 of /Users/computername/Sites/themename/mysite/code/Pages/HomePage.php If I refresh it comes right but then if I go to add something through a

Can I override a composer.json dependency to remove it?

送分小仙女□ 提交于 2019-12-23 15:53:08
问题 I know it's possible to override a composer dependency using: "some/module": "1.0.0 as 2.0.0", But is it possible to entirely remove a dependency that one of my dependencies requires? The issue is that I am requiring "cwp/cwp-recipe-basic": "1.1.0", which can be found here. That package is simply another list of dependencies, however I do not want one of those dependencies. Is there any way of telling composer to ignore that one dependency? E.g. "cwp/cwp-recipe-basic": "1.1.0", "silverstripe

How to automaticaly publish files uploaded to a dataobject in Silverstripe model admin

北慕城南 提交于 2019-12-23 09:27:51
问题 In Silverstripe 4 a file that is uploaded must be published before it is visible to the public side of the site. If I create a $Page with a $has_one Image::Class and then also assign that image to $owns[] the uploaded image will be published when I publish the page. However If I create the following data object structure it will not. Class Item extends DataObject{ $has_one[ 'ItemImage'=>Image::Class, 'Catalog'=>'Catalog' ]; $owns[ 'ItemImage' ] } Class Catalog extend DataObject{ $has_many[

Silverstripe 3.1 - resize image on upload

痞子三分冷 提交于 2019-12-23 02:56:18
问题 I want to resize the images while uploading them to save storrage. I tried it like this $visual = new UploadField('Visual', _t('Dict.PREVIEW_IMAGE', 'Preview Image')); $visual->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); $visual->setFolderName('news/' . $this->ID); $visual->resizeByHeight(10); but the result was an whitescreen in the backend. Is it possible to resize the images on upload? What am I doing wrong? thank you in advance 回答1: Before you read the answer, please rethink

Silverstripe DataObject - drag and drop ordering

时光毁灭记忆、已成空白 提交于 2019-12-22 11:09:27
问题 Silverstripe DataObject - I want to add drag and drop ordering to a current Class that extends dataobject like what exists for pages. So when dropped it updates an OrderBy field for all the dataobjects in that view. I created the class and can freely edit one item at a time, but a simple drag and drop ordering would make it so much easier but I can not see any such extensions currently on Dataobjects only on Pages. 回答1: In SilverStripe 3.1 there are a few excellent modules that give you this

How to add Custom button and its functionality in Admin Silverstripe?

强颜欢笑 提交于 2019-12-22 05:18:22
问题 How to add Custom button and its functionality in Admin Silverstripe? Please tell me solution. Custom Button add only in one menu. 回答1: Like @wmk mentioned in the comments, you can just take the framework code for GridFieldPrintButton as a base and go from there. SilverStripe also have a basic tutorial for creating a custom ActionProvider. Rather than rehash the tutorial here, I will provide you a very basic custom action provider that you can copy and extend to do what you need. While you

How to translate $url_handlers?

筅森魡賤 提交于 2019-12-21 05:52:03
问题 I have a situation where I need to translate the following $url_handlers for different countries. So on an english site the URL looks like this: http://website.com/gyms/boston/group-training I need to be able to translate the "group-training" part of the URL. I have translated the rest of the site using the _t() method throughout. My current setup: class GymLocationPage_Controller extends Page_Controller { private static $allowed_actions = array( 'currentSpecials', 'sevenDayFreeTrial',