Hi
I have next code
class LitCategory extends Page {
private static $many_many = array(
'LitEntrys' => 'LitEntry'
);
}
class LitEntry extends DataObject {
private static $belongs_many_many = array(
'LitCategorys' => 'LitCategory',
);
public function getCMSFields() {
$gridFieldConfig = GridFieldConfig_RelationEditor::create();
$gridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
$gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
$gridfield = new GridField("LitCategorys", "Blog Categorys", $this->LitCategorys(), $gridFieldConfig);
$fields->addFieldToTab('Root.LitCategorys', $gridfield);
}
}
When I try link LitCategory to LinEntry, for example I type in GridField "земн" (look at atache) silverstripe return to me list LitCategorys from all site languages .
Silverstripe generate next query:
SELECT DISTINCT `SiteTree_Live`.`ClassName`, `SiteTree_Live`.`Created`, `SiteTree_Live`.`LastEdited`, `SiteTree_Live`.`URLSegment`, `SiteTree_Live`.`Title`, `SiteTree_Live`.`MenuTitle`, `SiteTree_Live`.`Content`, `SiteTree_Live`.`MetaDescription`, `SiteTree_Live`.`ExtraMeta`, `SiteTree_Live`.`ShowInMenus`, `SiteTree_Live`.`ShowInSearch`, `SiteTree_Live`.`Sort`, `SiteTree_Live`.`HasBrokenFile`, `SiteTree_Live`.`HasBrokenLink`, `SiteTree_Live`.`ReportClass`, `SiteTree_Live`.`CanViewType`, `SiteTree_Live`.`CanEditType`, `SiteTree_Live`.`Locale`, `SiteTree_Live`.`Priority`, `SiteTree_Live`.`IsTitleHide`, `SiteTree_Live`.`Version`, `SiteTree_Live`.`ParentID`, `LitCategory_Live`.`ItemsPerPage`, `LitCategory_Live`.`Paginate`, `LitCategory_Live`.`Templ`, `SiteTree_Live`.`ID`, CASE WHEN `SiteTree_Live`.`ClassName` IS NOT NULL THEN `SiteTree_Live`.`ClassName` ELSE 'SiteTree' END AS `RecordClassName` FROM `SiteTree_Live` LEFT JOIN `LitCategory_Live` ON `LitCategory_Live`.`ID` = `SiteTree_Live`.`ID`
WHERE
(`SiteTree_Live`.`ID`
NOT IN (SELECT DISTINCT `SiteTree_Live`.`ID` FROM `SiteTree_Live` LEFT JOIN `LitCategory_Live` ON `LitCategory_Live`.`ID` = `SiteTree_Live`.`ID` INNER JOIN `LitCategory_LitEntrys` ON `LitCategory_LitEntrys`.`LitCategoryID` = `SiteTree_Live`.`ID`
WHERE
(`LitCategory_LitEntrys`.`LitEntryID` = '479')
AND (`SiteTree_Live`.`ClassName` IN ('LitCategory'))
AND (`SiteTree_Live`.`Locale` = 'uk_UA')
)
)
AND ((`SiteTree_Live`.`Title` LIKE '%земн%') OR (`SiteTree_Live`.`Content` LIKE 'земн%'))
AND (`SiteTree_Live`.`ClassName` IN ('LitCategory'))
// how to insert here the following filter:
// AND (`SiteTree_Live`.`Locale` = 'uk_UA')
ORDER BY `SiteTree_Live`.`Title` ASC LIMIT 20
Translatable add locale filter to inner query, but not add this (AND (`SiteTree_Live`.`Locale` = 'uk_UA')) to outer query.
How to add locale filter : AND (`SiteTree_Live`.`Locale` = 'uk_UA') befor ORDER ... ?