Change seo title
This commit is contained in:
@@ -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 <info@innhouse.pl>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,11 @@
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
{/block}
|
||||
{block name='head_seo'}
|
||||
<title>{block name='head_seo_title'}{$page.meta.title}{/block}</title>
|
||||
<title>
|
||||
{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}
|
||||
</title>
|
||||
{hook h="displayAfterTitleTag"}
|
||||
<meta name="description" content="{block name='head_seo_description'}{$page.meta.description}{/block}">
|
||||
<meta name="keywords" content="{block name='head_seo_keywords'}{$page.meta.keywords}{/block}">
|
||||
@@ -65,21 +69,21 @@
|
||||
|
||||
{block name='hook_extra'}{/block}
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
console.log('test');
|
||||
(function waitForElement() {
|
||||
const targetSelector = '.remaining-amount-to-free-shipping-container';
|
||||
const destinationSelector = '#tc-container';
|
||||
<script type="text/javascript">
|
||||
console.log('test');
|
||||
(function waitForElement() {
|
||||
const targetSelector = '.remaining-amount-to-free-shipping-container';
|
||||
const destinationSelector = '#tc-container';
|
||||
|
||||
const targetElement = document.querySelector(targetSelector);
|
||||
const destinationElement = document.querySelector(destinationSelector);
|
||||
const targetElement = document.querySelector(targetSelector);
|
||||
const destinationElement = document.querySelector(destinationSelector);
|
||||
|
||||
if (targetElement && destinationElement) {
|
||||
destinationElement.insertBefore(targetElement, destinationElement.firstChild);
|
||||
} else {
|
||||
// Czekaj i sprawdź ponownie za 200 ms
|
||||
setTimeout(waitForElement, 200);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
if (targetElement && destinationElement) {
|
||||
destinationElement.insertBefore(targetElement, destinationElement.firstChild);
|
||||
} else {
|
||||
// Czekaj i sprawdź ponownie za 200 ms
|
||||
setTimeout(waitForElement, 200);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
{/literal}
|
||||
Reference in New Issue
Block a user