Hi Everyone,
I'm working with the 2.4 svn build, and use the get_by_link function, it works really well.
But in this particular case it wont work:
I try to get a page that is currently in saved mode but not publish. and the get_by_link can't see it, I put the cache to false but same result.
I also try the switching the stage mode and no succes here is my method:
public function LocalizePage($url) {
$page = SiteTree::get_by_link($url, false);
if($page && ($page->Locale != Translatable::get_current_locale())) {
$page = $page->getTranslation(Translatable::get_current_locale());
return $page->Link();
} else {
$oldMode = Versioned::get_reading_mode();
Versioned::reading_stage('Stage');
$page = SiteTree::get_by_link($url, false);
Versioned::set_reading_mode($oldMode);
if($page && ($page->Locale != Translatable::get_current_locale())) {
$page = $page->getTranslation(Translatable::get_current_locale());
return $page->Link();
}
}
return $url;
}
thanks
Cristian