Jump to content

Edit History

apavlinets

apavlinets

Please tell me how to set a condition for changing the default language for a given page (index - home page).

I'll give an example.
By default, in the admin panel, the ru language and the module have removed the identifier on pages with the default language.
Pages submitted to the index google.
You need to set the main page uk but without an identifier, and the links will already work with an identifier.

I look in the direction of adding a condition to the controller (class) to check the type ...

{ if page==index} $default_language == <id2> { else} normal processing

Tell me where and how to register such a condition

 

 

It seems to have found a place in the module ... or rather, in the override of the class that the Link.php module uses

protected function getLangLink($id_lang = null, Context $context = null, $id_shop = null)
{
if (Configuration::get('FSAU_REMOVE_DEFAULT_LANG', null, null, $id_shop) &&
Language::isMultiLanguageActivated()) {
if (!$id_lang) {
if (is_null($context)) {
$context = Context::getContext();
}
$id_lang = $context->language->id;
}
if ($id_lang == Configuration::get('PS_LANG_DEFAULT', null, null, $id_shop)) {
return '';
}
}
return parent::getLangLink($id_lang, $context, $id_shop);
}

it remains to write a rule for the index(home page) page

apavlinets

apavlinets

Please tell me how to set a condition for changing the default language for a given page (index - home page).

I'll give an example.
By default, in the admin panel, the ru language and the module have removed the identifier on pages with the default language.
Pages submitted to the index google.
You need to set the main page uk but without an identifier, and the links will already work with an identifier.

I look in the direction of adding a condition to the controller (class) to check the type ...

{ if page==index} $default_language == <id2> { else} normal processing

Tell me where and how to register such a condition

 

 

It seems to have found a place in the module ... or rather, in the override of the class that the Link.php module uses

protected function getLangLink($id_lang = null, Context $context = null, $id_shop = null)
{
if (Configuration::get('FSAU_REMOVE_DEFAULT_LANG', null, null, $id_shop) &&
Language::isMultiLanguageActivated()) {
if (!$id_lang) {
if (is_null($context)) {
$context = Context::getContext();
}
$id_lang = $context->language->id;
}
if ($id_lang == Configuration::get('PS_LANG_DEFAULT', null, null, $id_shop)) {
return '';
}
}
return parent::getLangLink($id_lang, $context, $id_shop);
}

it remains to write a rule for the index page

apavlinets

apavlinets

Please tell me how to set a condition for changing the default language for a given page (index).

I'll give an example.
By default, in the admin panel, the ru language and the module have removed the identifier on pages with the default language.
Pages submitted to the index.
You need to set the main page uk but without an identifier, and the links will already work with an identifier.

I look in the direction of adding a condition to the controller (class) to check the type ...

{ if page==index} $default_language == <id2> { else} normal processing

Tell me where and how to register such a condition

 

 

It seems to have found a place in the module ... or rather, in the override of the class that the Link.php module uses

protected function getLangLink($id_lang = null, Context $context = null, $id_shop = null)
{
if (Configuration::get('FSAU_REMOVE_DEFAULT_LANG', null, null, $id_shop) &&
Language::isMultiLanguageActivated()) {
if (!$id_lang) {
if (is_null($context)) {
$context = Context::getContext();
}
$id_lang = $context->language->id;
}
if ($id_lang == Configuration::get('PS_LANG_DEFAULT', null, null, $id_shop)) {
return '';
}
}
return parent::getLangLink($id_lang, $context, $id_shop);
}

it remains to write a rule for the index page

×
×
  • Create New...