zitu4life Posted March 28, 2021 Share Posted March 28, 2021 Hello there I am looking a hook that will auto detect if client is logging in on client area, to override LOGO url to clientarea.php Usually if we click on logo it will take us to index.php page, but I would like it to forward to clientarea.php if client is logged in. So every time I click on logo it will forward to picture below page. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 29, 2021 Share Posted March 29, 2021 14 hours ago, zitu4life said: I am looking a hook that will auto detect if client is logging in on client area, to override LOGO url to clientarea.php but in your case, you should just need to wrap the return with an IF statement to check whether the client is logged in... <?php # Change Logo URL Hook # Written by brian! function change_logo_url_hook($vars) { $client = Menu::context('client'); if ($client) { return "<script> $(function(){ $('a.logo').attr({href:'clientarea.php',target:'_blank'}); }); </script>"; } } add_hook("ClientAreaFooterOutput", 1, "change_logo_url_hook"); optionally, it's also going to open in a new window/tab - if you don't want that, then just remove the ,target:'_blank' part. 0 Quote Link to comment Share on other sites More sharing options...
Impressive Themes Posted March 30, 2021 Share Posted March 30, 2021 The above code will not work when using search engine friendly urls, for example if you're on the domain renewals page the page url would be: yoursite.com/cart/domain/renew The above code would cause the logo to link to the following url resulting in a 404 error: yoursite.com/cart/domain/clientarea.php You can overcome this be utilising the {$webroot} variable. I've updated the code above to include this, as well as function for both the six and twenty-one theme: <?php # Change Logo URL Hook # Written by brian! function change_logo_url_hook($vars) { $client = Menu::context('client'); if ($client) { return "<script> $(function(){ $('a.logo').attr({href:'{$webroot}/clientarea.php',target:'_blank'}); $('a.navbar-brand').attr({href:'{$webroot}/clientarea.php',target:'_blank'}); }); </script>"; } } add_hook("ClientAreaFooterOutput", 1, "change_logo_url_hook"); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 30, 2021 Share Posted March 30, 2021 51 minutes ago, Impressive Themes said: You can overcome this be utilising the {$webroot} variable. not in the way you've done it - it wouldn't work. <?php # Change Logo URL Hook # Written by brian! function change_logo_url_hook($vars) { $client = Menu::context('client'); if ($client) { return "<script> $(function(){ $('a.logo').attr({href:'".$vars['WEB_ROOT']."/clientarea.php',target:'_blank'}); $('a.navbar-brand').attr({href:'".$vars['WEB_ROOT']."/clientarea.php',target:'_blank'}); }); </script>"; } } add_hook("ClientAreaFooterOutput", 1, "change_logo_url_hook"); 1 hour ago, Impressive Themes said: as well as function for both the six and twenty-one theme: in practice, you should probably detect which theme is being used and only return the applicable CSS. 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.