kane

Kia ora all. Does anyone know if there is a simple way via the ORM to achieve the following: Sorting Discussions by latest Reply.

  1. class Discussion...
  2. private static $has_many = [
  3. 'Replies' => Reply
  4. ];
jkersu

From the top of my head, these are 2 ways you can do it @dig: Option 1 - Return the Join object itself from a custom function: $singleObj->ManyManyThroughRelationshipName()->byID($ID)->getJoin() then call the field in the template

Option 2 - Return the many-many through relation then use dot-notation in the template: return $singleObj->ManyManyThroughRelationshipName() in the controller then in the template something like:

  1. <% loop $listfunction %>
  2. $getJoin.extraField
  3. <% end_loop %>

Option 3 - Another way someone else knows 🤣

dig

Hi All, How can I access the extra fields on a many many through object from within a template? 😕

Joe

just looking at the code before it throws that error, it looks as if it’s probably something like _t(static::class.'.KEY') in a PHP class

but, i’ll also say that the error being thrown is a warning. not an error, so ideally that being thrown shouldn’t be breaking anything

Joe

might be worth dropping a breakpoint in /vendor/silverstripe/framework/src/i18n/TextCollection/i18nTextCollector.php on line 677 to stop the process as it’s about to throw the error, and see if the other variables in that function give enough context to determine where the problem is

Shaun Moore

I have SilverShop, trying to run i18nTextCollectorTask and it fails on this function inside ProductCategoryController.php [User Warning] Error concatenating localisation key

  1. /**
  2.   * Sorting controls
  3.   *
  4.   * @return ListSorter sorter
  5.   */
  6. public function getSorter()
  7. {
  8. $options = array();
  9. foreach (ProductCategory::config()->sort_options as $k => $v) {
  10. // make the label translatable
  11. $k = _t(ProductCategory::class . '.' . $k, $k);
  12. $options[$k] = $v;
  13. }
  14.  
  15. $sorter = ListSorter::create($this->request, $options);
  16. $this->extend('updateSorter', $sorter);
  17.  
  18. return $sorter;
  19. }
asp

Anyone occured problems with the silverstripe-cookie-consent module with android? https://github.com/TheBnl/silverstripe-cookie-consent Using a Samsung S9 (Android 10) the "accept all" Button just doesnt work (modal window stays open), everywhere else it works ...

Show 1 attachment(s)
TheBnl/silverstripe-cookie-consent

GDPR compliant cookie popup and consent checker

Hide attachment content