Skip to content

Instantly share code, notes, and snippets.

View webspilka's full-sized avatar

Vitaliy Tsymbalyuk webspilka

View GitHub Profile
@webspilka
webspilka / PCategory.php
Created June 2, 2021 20:14
[Emergency] Uncaught SilverStripe\ORM\Connect\DatabaseException: Couldn't run query: UPDATE "" SET "SortOrder" = 1 WHERE "" = 1 AND "" = 6 Incorrect table name ''
<?php
// PCategory.php
// namespace App\Web;
// use Page;
use SilverStripe\Forms\NumericField;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor;
https://github.com/bummzack/translatable-dataobject/issues/24
Similar situation here.
Though not tested yet, I think i will use something like this (in a DataExtension for Page or SiteTree), so i won't have to write special functions for every DataObject and every page link.
Maybe this helps somebody.
<?php
public function LocalizedMaster($fallbackToDefault=false) {
$master = $this->owner->Master();
$currLocale = Translatable::get_current_locale();
if($master && $master->hasTranslation($currLocale)){
@webspilka
webspilka / ss_fluent_locales.php
Last active November 25, 2015 13:03
Silverstripe fluent locale switch
<?php
// Отримати сслику на головну сторінку сайту
// для локалі по замовчанню отримуєм / , для всіх інших /locale-alias/
public function getBaseURL($locale = null){
if(empty($locale)) $locale = Fluent::current_locale();
// Build domain-specific base url
$base = Director::baseURL();
if($locale === Fluent::default_locale()) return $base;