Regia Posted August 15, 2012 Share Posted August 15, 2012 Hi, I am looking for a way to change the title of the page from the cart template - is it possible to "force" a change? Currently <title> says "Shopping cart - [site name]" - I can change the text in the translation file, but it will not work in my case, as I have two product offerings with different cart templates, and if I change the text this way , then the new title will be the same of both products - but my goal is to have different titles. 0 Quote Link to comment Share on other sites More sharing options...
RebelOne Posted August 15, 2012 Share Posted August 15, 2012 Look into the clientAreaPage hook point. You should be able to use a conditional statement to check for the product_id or possibly the cart template and set the $title variable accordingly. 0 Quote Link to comment Share on other sites More sharing options...
Regia Posted August 17, 2012 Author Share Posted August 17, 2012 Look into the clientAreaPage hook point. You should be able to use a conditional statement to check for the product_id or possibly the cart template and set the $title variable accordingly. Thanks. Where I can find the cart template variable name? As the $template returns my page template name, and not my cart template name. Also, I tried to test this in the hooks file: $pagetitle = "Споделен хостинг - РЕГИЯ"; But it doesnt set up the page title. Am I doing something wrong? 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted August 17, 2012 Share Posted August 17, 2012 What you want to do is return an array with a containing new variables for pagetitle and companyname since the title is displayed as {$pagetitle} - {$companyname}. return array("pagetitle" => "custom page title", "companyname" =>"custom company name"); In your hook you can check if it is a shopping cart page by looking at the filename variable, it will show cart or you can look at the pagetitle variable before you change it. 0 Quote Link to comment Share on other sites More sharing options...
RebelOne Posted August 17, 2012 Share Posted August 17, 2012 Put {debug} at the top of your header.tpl file. Then open your site in a browser. A popup window will show you all the variables you have to work with in your page. All the available variables are held in an array called $vars. I think there will be a $carttpl var and a $productsinfo array, that may be useful to determine what page you are on. To modify from a hooks file you need to do $vars['pagetitle'] = 'abc123'; 0 Quote Link to comment Share on other sites More sharing options...
Regia Posted August 17, 2012 Author Share Posted August 17, 2012 Thanks. It works perfectly now. Here is the code, in case someone needs a similar solution: <?phpfunction change_page_title($vars) { $pagetitle = $vars['pagetitle']; $template = $vars['carttpl']; if ($template=="order for template") { return array("pagetitle" => "Page title", "companyname" =>"Company name"); } } add_hook("ClientAreaPage",1,"change_page_title"); ?> 0 Quote Link to comment Share on other sites More sharing options...
Shubham Ghasi Posted July 19, 2021 Share Posted July 19, 2021 On 8/18/2012 at 3:50 AM, Regia said: Thanks. It works perfectly now. Here is the code, in case someone needs a similar solution: Where i have to use this code? Please help me 0 Quote Link to comment Share on other sites More sharing options...
HostingMe Posted July 19, 2021 Share Posted July 19, 2021 7 hours ago, Shubham Ghasi said: Where i have to use this code? You would need to create a file in the hooks folder located: ~/includes/hooks 0 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.