Lek Posted November 18, 2016 Share Posted November 18, 2016 Hi, I just read this old thread: https://forum.whmcs.com/showthread.php?101427-Set-title-of-page-using-an-action-hook So I would like to have different title for each given cart page. For example a different title to cart.php?gid=3 and another title to cart.php?gid=6. Is this syntax correct? <?php function hook_setpagetitle($vars){ $pagetitle = "Set Page Title Here"; // also you can set title per page URL if ($vars['contact.php']=='contacttitle'){ $pagetitle = "Contact us now"; } elseif ($vars['cart.php?gid=6']=='carttitle'){ $pagetitle = "Email services"; } return array("pagetitle" => $pagetitle); } add_hook("ClientAreaPage", 1, "hook_setpagetitle"); ?> And should i remove $pagetitle = "Set Page Title Here"; ? Thank you to everybody 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 18, 2016 Share Posted November 18, 2016 Lek, I think you deviated too far from sentq's original code - something like the following should work... <?php function hook_setpagetitle($vars){ // also you can set title per page URL if ($vars['filename']=='index'){ $pagetitle = "Home Page"; } elseif ($vars['filename']=='cart' && $vars['gid']){ $pagetitle = $vars['groupname']; } elseif ($vars['filename']=='contact'){ $pagetitle = "Contact us now"; } if ($pagetitle) { return array("pagetitle" => $pagetitle); } } add_hook("ClientAreaPage", 1, "hook_setpagetitle"); ?> when in the cart, it should automatically show the Product Group Name for each group - so that should remove the need to add each group manually to your hook code! you should be able to work your way through all steps of the cart using the existing variables - $templatefile should be useful for the remaining cart steps, but you may need to use other variables too. i'd be inclined to remove the "Set Page Title Here" line and let WHMCS use it's own default title for pages you haven't specified... the above hook will only change the pagetitle if the conditions specified in the hook are met; if they aren't, then the hook doesn't make any changes and WHMCS will use what it normally uses for each page. 1 Quote Link to comment Share on other sites More sharing options...
Lek Posted November 20, 2016 Author Share Posted November 20, 2016 Perfect! Thank you, bye. Lek 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.