diff --git a/override/controllers/front/listing/CategoryController.php b/override/controllers/front/listing/CategoryController.php index 1d6e8f7a..70c9966e 100644 --- a/override/controllers/front/listing/CategoryController.php +++ b/override/controllers/front/listing/CategoryController.php @@ -46,4 +46,39 @@ class CategoryController extends CategoryControllerCore public function getTemplateVarSubCategoriesPublic() { return $this->getTemplateVarSubCategories(); } + + /* + * Override na tytuł kategorii z podstronami + * date: 21.07.2025 + * author: Tomasz Załucki + */ + public function getTemplateVarPage() + { + $page = parent::getTemplateVarPage(); + if (Validate::isLoadedObject($this->category) && $this->category->active) { + + // Pobierz oryginalny tytuł kategorii i ustaw go jako meta title + // Domyślnie tytuł pobierany jest z presentera i pokazuje w nawiasie numer podstrony + $categoryTitle = $this->category->name; + $shopName = Configuration::get('PS_SHOP_NAME'); + $currentPage = (int) Tools::getValue('page', 1); + $newMetaTitle = $categoryTitle . ' - ' . trim($shopName); + + + if ($currentPage > 1) { + $newMetaTitle .= ' - Strona ' . $currentPage; + } + + $page['meta']['title'] = $newMetaTitle; + + $metaTitle = trim($this->category->meta_title); + if ($metaTitle !== '') { + $page['meta']['seo_title'] = $metaTitle; + } else { + $page['meta']['seo_title'] = null; + } + } + + return $page; + } } diff --git a/themes/charme/templates/_partials/head.tpl b/themes/charme/templates/_partials/head.tpl index a96b18f2..64d68ce3 100644 --- a/themes/charme/templates/_partials/head.tpl +++ b/themes/charme/templates/_partials/head.tpl @@ -29,7 +29,11 @@ {/block} {block name='head_seo'} - {block name='head_seo_title'}{$page.meta.title}{/block} + + {block name='head_seo_title'} + {if isset($page.meta.seo_title) && $page.meta.seo_title|trim != ''}{$page.meta.seo_title}{else}{$page.meta.title}{/if} + {/block} + {hook h="displayAfterTitleTag"} @@ -65,21 +69,21 @@ {block name='hook_extra'}{/block} {literal} - + if (targetElement && destinationElement) { + destinationElement.insertBefore(targetElement, destinationElement.firstChild); + } else { + // Czekaj i sprawdź ponownie za 200 ms + setTimeout(waitForElement, 200); + } + })(); + {/literal} \ No newline at end of file