silverstripe

SIlverStripe - No data written onBeforeWrite

落爺英雄遲暮 提交于 2019-12-10 12:14:09
问题 Related to this issue, a DataObject extended with onBeforeWrite method doesn't write a specific property value on DB. In detail: DataObject: [...] /** * Classe Prodotto */ class Prodotto extends DataObject { // Dichiarazione Proprietà private static $db = [ [...] 'PrezzoIva' => 'Currency', [...] onBeforeWrite method: /** * Metodo gestione azioni salvataggio * Calcolo automatico prezzo lordo e scontato * Setter * @return void */ public function onBeforeWrite() { // Controllo Record if (!$this-

SilverStripe behind load balancer

可紊 提交于 2019-12-10 10:54:54
问题 I've got an instance of SilverStripe running on two servers behind an AWS load balancer. To share the session information I'm running Elasticache Redis server. I'm setting my php session store info as such: ini_set('session.save_handler', 'redis'); ini_set('session.save_path', 'tcp://127.0.0.1:6379'); After I've signed into the admin section of the CMS I can jump between servers and it remembers me, however when switching between sections in the CMS the main section doesn't render (an AJAX

SilverStripe - limiting the number of many relations a dataobject can have

瘦欲@ 提交于 2019-12-09 03:39:00
问题 If I have a $has_many relationship that I want to manage with a GridField in the cms, how would I go about putting a limit on the number of how many relations one object can have? Is this possible? Can I do this in the model or would it have to be a check I add into the GridField I'm using to add and remove relations? I'm looking at implementing GridField_SaveHandler to make a custom GridFieldComponent but not sure how I can use this to abort the save if i detect something is wrong. 回答1: the

Silverstripe. Uploaded to live. Getting “SilverStripe Framework requires a $databaseConfig defined.”

限于喜欢 提交于 2019-12-08 16:33:14
问题 I've uploaded a site to the live server, imported the database and updated the db connection info in mysite/_config.php but am getting the following error: SilverStripe Framework requires a $databaseConfig defined. This appears to come from framework/main.php where it is checking my to make sure my config is defined. Here is my config: global $databaseConfig; $databaseConfig = array( "type" => 'MySQLDatabase', "server" => 'localhost', "username" => 'xxxxx', "password" => 'xxxxx', "database" =

Silverstripe - Looping over non-associative array in template

那年仲夏 提交于 2019-12-08 16:14:03
问题 How can this be done inside of a template? I have done it with ArrayData using the key in the template loop to access values from the template, but if I have an arbitrary array of strings with no keys, what variable do I use to access the values? If in my controller I have this: public function ArrayList() { $ArrayList = new ArrayList(array('this', 'is', 'a', 'test')); return $ArrayList; } And this in my template: <% loop $ArrayList %>1<% end_loop %> What do I put in place of 1 to get the

SilverStripe - Undefined Index on DataObject onBeforeWrite

陌路散爱 提交于 2019-12-08 13:43:24
问题 Following the official SS guide on DataObject extension, I'm occurring on this exception: PHP Notice: Undefined index: PrezzoIva Project panorama: a value must be computed and saved in pair with the other DataObject properties, before the main write() execution. Here's the situation (on SS 4.0.3): [...] /** * Classe Prodotto */ class Prodotto extends DataObject { // Dichiarazione Proprietà private static $db = [ [...] 'PrezzoIva' => 'Currency', [...] onBeforeWrite method: /** * Metodo

[Silverstripe 2.4]: How to get records containing columns from one-to-many relationship?

北战南征 提交于 2019-12-08 10:52:14
问题 there are two dataobject classes "A" and "B" having one-to-many relationship. I want to get data containing columns from both parent and child dataobject. How to achieve this in Silverstripe 's ORM or SQL Query. Example: Dataobject "A" has two events and first event contain one date info(start and end date). Second event contains two dates info (start and end date). I want to query database to get information containing columns from both "A" and "B" and it should shows 3 row as result. one

Store sensitiv data in Silverstripe 3.1

筅森魡賤 提交于 2019-12-08 08:43:11
问题 I want to store sensitive informations (mainly passwords) in a dataobject in silverstripe. The Data need to be stored crypted in the database. If i call this field in my template, I need the data decrypted. But I don't know how to do this. Can someone point me in the right direction? Thx! 回答1: What you could do is create a Password DataObject with the Member object having a one to many relationship to the Password object. You can use the salt of the logged in Member with a 2 way php encrypt

How to fetch value from url in silverstripe

孤者浪人 提交于 2019-12-08 04:18:26
问题 I want to print value 5 on the ss page. www.xyz.com?a=5. How to fetch url data in silverstripe? Any help is accepeted. 回答1: In your controller that your Silverstripe template is for, you can retrieve "GET" (aka. query string) by returning the result of $this->getRequest()->getVar('a') in a function on your controller. It is good practice to use $this->getRequest()->getVar('a') over $_GET['a'] as SilverStripe will automatically sanitise the string. When your code is not in the controller (so

SilverStripe: changing the order of GridField input elements

旧时模样 提交于 2019-12-08 04:03:30
问题 So, disclaimer first: I'm a bit of a noob when it comes to SilverStripe, but this one is vexxing me. I'm using GridField to add and edit the entries in a DataObject. This is all well and good, and works perfectly. The only thing I can't figure out is how to change the order of the EDITABLE fields - this isn't the initial table display of the entries (which is set by $config), it's the actual input fields once you click "add new" or go to edit a record. At the moment the Image uploadForm and