-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
findRaw() paths do not account for user language #1964
Comments
@Toutouwai It doesn't look like PagesRaw supports multi-language path properties at present. I'm not sure to what extent it can, as those are supplied to Page objects via hooks. And there are no Page objects when using findRaw(). I suppose it could use pages_paths for some cases, but those aren't guaranteed to be present, so would not be a complete solution. |
@ryancramerdesign, not sure what you mean about not guaranteed to be present as the PagePaths module has to be installed for Could there perhaps be new options for the plurals For a temporary solution I'm doing this: // Get some data from findRaw()
$data = $pages->findRaw("template=basic-page", ['title']);
// Find paths that match the IDs
$ids = array_keys($data);
$sql = "SELECT pages_id, language_id, path FROM `pages_paths` WHERE pages_id IN(" . implode(',', $ids) . ")";
$query = $database->query($sql);
$paths_data = $query->fetchAll(\PDO::FETCH_GROUP|\PDO::FETCH_ASSOC);
// Merge in the paths indexed by language ID
foreach($data as $id => $item) {
foreach($paths_data[$id] as $path) {
$data[$id]['paths'][$path['language_id']] = '/' . $path['path'] . '/';
}
} |
@ryancramerdesign, as a test I added the code below at line 1676 of PageFinder.php $paths_join = 'pages_paths ON pages_paths.pages_id=pages.id';
$user = $this->wire()->user;
if($user->language && !$user->language->isDefault()) {
$paths_join .= " AND pages_paths.language_id=" . $user->language->id;
}
$query->leftjoin($paths_join); And now it returns paths for the user's language. Could an option for something like this be added too? Perhaps rather than based off the user language there would be an option to pass in a language and |
Short description of the issue
When getting page paths via
$page->findRaw()
, only the path for the default language is returned, regardless of the$user
language.Paths for each language are in the
pages_paths
table but I don't see a way to tellfindRaw()
which language path is wanted. Is there support for multi-language paths infindRaw()
? Is there a way to havefindRaw()
return all the language paths that exist for pages in the results?Setup/Environment
The text was updated successfully, but these errors were encountered: