jacksony Posted June 12, 2017 Share Posted June 12, 2017 Hi! Can someone advise how can we use hook to change title of a page? We want to change for cart.php?a=add&domain=register. The code below should work (although it is for all cart pages, although we want it for domain pages only), but don't.. <?php function hook_setpagetitle($vars){ if ($vars['filename']=='cart'){ $pagetitle = "Domain Name Registration"; } return array("pagetitle" => $pagetitle); } add_hook("ClientAreaPage", 1, "hook_setpagetitle"); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 12, 2017 Share Posted June 12, 2017 <?php function hook_setpagetitle($vars) { if ($vars['templatefile'] == 'domainregister'){ $pagetitle = "Domain Name Registration"; } return array("pagetitle" => $pagetitle); } add_hook("ClientAreaPageCart", 1, "hook_setpagetitle"); 0 Quote Link to comment Share on other sites More sharing options...
jacksony Posted June 12, 2017 Author Share Posted June 12, 2017 Wow! You are a life saver! +1 to you! 0 Quote Link to comment Share on other sites More sharing options...
companyglue Posted February 19, 2021 Share Posted February 19, 2021 Hey guys, Sorry to bump such an old post but haven't found a solution elsewhere and this is topic is the closest to a solution I've found. I have modified the header.tpl title to the following: <title>{if $groupname}{$groupname}{else}{$pagetitle}{/if}{if $kbarticle.title} - {$kbarticle.title}{/if} - {$companyname}</title> This works great because it has significantly improved SEO throughout my system, specially on the cart pages which only showed Shopping Cart for all product/services. However, the Domain and Transfer pages still show the Shopping Cart title, I tried implementing the code provided by Brian and it does the trick for the Domain page and works well BUT now the title for all the shopping cart related pages is gone, showing only "{companyname} -(blank)". I've been trying to play around with the code to make the Shopping Cart title appear again while also including a title for the Domain Transfer Page without success. Any help would be much appreciated. 0 Quote Link to comment Share on other sites More sharing options...
Esquio Posted September 5, 2023 Share Posted September 5, 2023 I think is possible to edit header.tpl file with some if else cases. Where can I found the list of available variables at header.tpl? 0 Quote Link to comment Share on other sites More sharing options...
Esquio Posted September 7, 2023 Share Posted September 7, 2023 Mi workaround is the following: Edit the header.tpl file, inside the used theme folder, and you can configure <title> as this (my code is in Spanish language, but change with yours): {if $templatefile eq "pagebuilder" or $templatefile eq "homepage"} <title>{if $groupname}{$groupname}{else}{$pagetitle}{/if}{if $pagedata.meta_title}{$pagedata.meta_title}{else}{$pagedata.item.name} - {$companyname}{/if}</title> {elseif $templatefile == 'clientareadomains'} <title>Gestión de dominios contratados - {$companyname}</title> {elseif $templatefile == 'clientareadomaindetails'} <title>{$domain} - Gestión de dominios contratados - {$companyname}</title> {elseif $templatefile == 'clientareaproducts'} <title>Gestión de servicios contratados - {$companyname}</title> {elseif $templatefile == 'clientareaproductdetails'} <title>{$domain} - Gestión de servicios contratados - {$companyname}</title> {elseif $templatefile == 'clientareainvoices'} <title>Mis facturas - {$companyname}</title> {elseif $templatefile == 'clientareadetails'} <title>Mis datos de cliente - {$companyname}</title> {elseif $templatefile == 'account-contacts-new'} <title>Contactos y subcuentas - {$companyname}</title> {elseif $templatefile == 'clientareasecurity'} <title>Seguridad de la cuenta - {$companyname}</title> {elseif $templatefile == 'clientareaemails'} <title>Emails recibidos como cliente - {$companyname}</title> {else} <title>{if $templatefile == 'viewannouncement'}{$title}{elseif $templatefile == 'announcements'}{lang key="news"}{elseif $kbarticle.title}{$kbarticle.title}{elseif $templatefile == 'knowledgebasecat'}{$kbcurrentcat.name}{else}{$pagetitle}{/if} - {$companyname}</title> {/if} 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.