eeerlend

oh, thanks @muskie9 - didn't know about that one

👍 (1)
eeerlend

so, something like;

  1. DataObject::get()->sort('Created desc')->limit(10)->sort('Created asc')
Possible?

eeerlend

...or do I need to do manual query for that?

eeerlend

Hi! I'm getting objects from DB, using filter, sort and limit. Is there a way, lets say - I want the 10 "newest" records Created desc sorted by Created asc?

eeerlend

Hi! I'm using custom routes that works fine in my ss4 application. But when I try to set the controller for

  1. '': 'HomeController'
that doesn't work. It just opens the page set as the home page in the cms. I've followed this; https://docs.silverstripe.org/en/4/developer_guides/controllers/routing/ ->
  1. ---
  2. Name: approutes
  3. After:
  4. - '#rootroutes'
  5. - '#coreroutes'
  6. ---
  7. SilverStripe\Control\Director:
  8. rules:
  9. 'teams//$Action/$ID/$Name': 'TeamController'
  10. 'player/': 'PlayerController'
  11. '': 'HomeController'
Can someone help me?

eeerlend

Hi! I find very little information about how to do a custom setter in silverstripe. Is this the proper way to do it? The reason I ask is that it gets triggered only when setting the param with the setter, not when I create them through objFromFixture in SilverStripe\Dev\SapphireTest (Not sure if they should).

  1. private static $db = [
  2. 'ExtPlayer' => 'Varchar',
  3. ]
  4. ...
  5. public function setExtPlayer($value) {
  6. // ... manipulate the value
  7. $this->setField('ExtPlayer', $value);
  8. }
eeerlend

Hard to debug - but namespacing issue! Solved

eeerlend

Figured out where the problem was, but not how to solve it. The fgetcsv command in SilverStripe\Dev\CSVParser sends in the enclosure param, which don't exist in my csv file (not possible to change, bad export options where the file is generated). So somehow, I need to get it to work without enclosed values. Now it is treating the line in the csv file as one field. Same with the header. 😞

eeerlend

Could it be since my fields aren't enclosed? public $enclosure = '';

eeerlend

All rows are getting imported, but without data

eeerlend

Hi! I struggle with getting a custom extension of SilverStripe\Dev\CsvBulkLoader to work in my model admin. Here are my files, after I've followed this guide; https://docs.silverstripe.org/en/4/developer_guides/integration/csv_import/

The importer doesn't seem to be used at all...

  1. <?php
  2. namespace My\Namespace;
  3. use SilverStripe\Dev\CsvBulkLoader;
  4.  
  5. class GameParticipationCsvBulkLoader extends CsvBulkLoader
  6. {
  7. public $delimiter = ';';
  8. public $enclosure = '';
  9. public $columnMap = [
  10. ''SomeSourceAttribute'' => ''SomeAttribute''
  11. ];
  12. }
  1. <?php
  2. namespace My\Namespace;
  3. use SilverStripe\ORM\DataObject;
  4. use SilverStripe\Security\Member;
  5.  
  6. class GameParticipation extends DataObject
  7. {
  8. private static $table_name = 'GameParticipation';
  9. private static $db = [
  10. 'SomeAttribute' => 'Varchar'
  11. ];
  12.  
  13. private static $summary_fields = [
  14. 'SomeAttribute'
  15. ];
  16. }
  1. <?php
  2. namespace My\Namespace;
  3. use SilverStripe\Admin\ModelAdmin;
  4. class GameAdmin extends ModelAdmin
  5. {
  6. private static $managed_models = [
  7. GameParticipation::class,
  8. ];
  9.  
  10. private static $model_importers = [
  11. GameParticipation::class => GameParticipationCsvBulkLoader::class,
  12. ];
  13. ....
  14. }