8.4.2 How to use Url::to on multilingual site?
Permalink
I use the following on a default locale:
which results inhttp://localhost/c5/index.php/booking/2... (booking is a single page).
I've copied the locale tree and rescanned it. But when I switch to another language, the above code still points to the default locale.
Is the Url::to multilingual? What should I do to make all my links multilingual?
Does tree rescanning only rescans hard coded links?
which results inhttp://localhost/c5/index.php/booking/2... (booking is a single page).
I've copied the locale tree and rescanned it. But when I switch to another language, the above code still points to the default locale.
Is the Url::to multilingual? What should I do to make all my links multilingual?
Does tree rescanning only rescans hard coded links?
That's also hard coding the locale, assuming you already know you have an 'en' one. I was wondering if there was a universal multilingual way of using the Url class.
If you are on a page A in language X, and you want the corresponding page B in language Y, you need to use the data configured in the "System & Settings" > "Multilingual" > "Page Report" dashboard page.
This can be done in the following way:
This can be done in the following way:
<?php use Concrete\Core\Localization\Localization; use Concrete\Core\Multilingual\Page\Section\Section; use Concrete\Core\Page\Page; use Concrete\Core\Support\Facade\Application; use Concrete\Core\Url\Resolver\Manager\ResolverManagerInterface; // Get the Application instance // See alsohttps://github.com/shahroq/whale_c5_cheat_sheet#application-app... $app = Application::getFacadeApplication(); // Get the current page $currentPage = Page::getCurrentPage(); // Get the multilingual section of the current page $currentMultilingualSection = Section::getBySectionOfSite($currentPage); // Check if the current page has a multilingual section, // otherwise get the multilingual section of the currently active locale
Viewing 15 lines of 32 lines. View entire code block.
/en/booking