ChrisTERiS Posted December 11, 2020 Share Posted December 11, 2020 Hello, Does anyone knows if something changed with App::getCurrentFilename() in a hook file? The code below was working fine before, but after upgrading to ver. 8 does not works. // Check for Cart pages if (App::getCurrentFilename() == 'cart') { $cart_page = 1; } else { $cart_page = 0; } Also I noticed something strange, but maybe this was even with older WHMCS version. I tried to use echo $cart_page but nothing appears in the page. Thank you Chris 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 11, 2020 Share Posted December 11, 2020 11 minutes ago, ChrisTERiS said: Does anyone knows if something changed with App::getCurrentFilename() in a hook file? The code below was working fine before, but after upgrading to ver. 8 does not works. I would think a bigger problem is that the filename for the cart in v8 might not necessarily be cart.php any more.... more often than not, it will now be index.php (depending on your Friendly URL settings)... https://demo.whmcs.com/index.php?rp=/store/shared-hosting however, you should still be able to use the code below to determine if you are in a cart page (and you can access $vars).. if ($vars['inShoppingCart']) that variable has existed for a while - certainly the last few major releases of v7 and in v8 and later... it should only exist if you're in the cart. 21 minutes ago, ChrisTERiS said: Also I noticed something strange, but maybe this was even with older WHMCS version. I tried to use echo $cart_page but nothing appears in the page. possibly depends on the hook point being used - certainly ClientAreaPage should display an echo / print of a variable. 0 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted December 11, 2020 Author Share Posted December 11, 2020 (edited) @brian! It's so frustrated for coders and designers when the framework change commonly used variables (and class name for designers). I wrote framework, as it's not only for WHMCS, same happen with vBulletin between ver. 3 - 4 -5, same with XenForo between 1-2, same with IPS. Thank you very much for your help. Can I dare to ask, how I can determine if I'm in the homepage (homepage.tpl). What variable works there instead of App::getCurrentFilename() == 'index'? Chris Edited December 11, 2020 by ChrisTERiS 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 12, 2020 Share Posted December 12, 2020 21 hours ago, ChrisTERiS said: It's so frustrated for coders and designers when the framework change commonly used variables (and class name for designers). ... and don't update their documentation to let users know! 21 hours ago, ChrisTERiS said: Can I dare to ask, how I can determine if I'm in the homepage (homepage.tpl). What variable works there instead of App::getCurrentFilename() == 'index'? if $vars is available, then I would use... if ($vars['templatefile'] == "homepage") { if it' not, then there are other options - including using Smarty to get the template; using specific hook pointss within hooks (I tend to avoid this if possible but it can be useful, e.g there is a hook point that is only triggered by homepage or clientareahome)... 1 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted December 12, 2020 Author Share Posted December 12, 2020 3 minutes ago, brian! said: .. and don't update their documentation to let users know! At least WHMCS, I've to admit it, has a very good documentation. But again, so many changes... so many... 😞 0 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted December 14, 2020 Author Share Posted December 14, 2020 Hello @brian! 2 full days working and I'm still unable to find a working solution. This code works for newsletter.php if (App::getCurrentFilename() == 'newsletter') { add_hook('ClientAreaSecondarySidebar', 4, function (MenuItem $secondarySidebar) { $secondarySidebar->removeChild('cms_mailing'); }); } This does not works if ($vars['templatefile'] == "homepage") { add_hook('ClientAreaSecondarySidebar', 5, function (MenuItem $secondarySidebar) { $secondarySidebar->removeChild('cms_mailing'); }); } This hides sidebar panel from all pages. Normal as all pages are with the new style index.php?rp=.... if (App::getCurrentFilename() == 'index') { add_hook('ClientAreaSecondarySidebar', 4, function (MenuItem $secondarySidebar) { $secondarySidebar->removeChild('cms_mailing'); }); } What on heck? There is nothing to identify the homepage? 🤪 - Chris 0 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted December 14, 2020 Author Share Posted December 14, 2020 For anyone who needs it. Maybe not the best solution, but works. if (pathinfo(trim($_SERVER['REQUEST_URI'], '/'), PATHINFO_FILENAME) == 'index' || trim($_SERVER['REQUEST_URI'], '/') == '') { add_hook('ClientAreaSecondarySidebar', 5, function (MenuItem $secondarySidebar) { $secondarySidebar->removeChild('cms_mailing'); }); } 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted December 14, 2020 Share Posted December 14, 2020 (edited) Hello I'm using the below action to check the template file. Not the best idea, but works add_hook('ClientAreaSidebars', 1, function($vars) { $primarySidebar = Menu::primarySidebar(); $secondarySidebar = Menu::secondarySidebar(); global $smarty; $template = $smarty->getTemplateVars('template'); $templatefile = $smarty->getTemplateVars('templatefile'); Edited December 14, 2020 by pRieStaKos 1 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted December 14, 2020 Author Share Posted December 14, 2020 28 minutes ago, pRieStaKos said: Hello I'm using the below action to check the template file. Not the best idea, but works add_hook('ClientAreaSidebars', 1, function($vars) { $primarySidebar = Menu::primarySidebar(); $secondarySidebar = Menu::secondarySidebar(); global $smarty; $template = $smarty->getTemplateVars('template'); $templatefile = $smarty->getTemplateVars('templatefile'); I believe that it should works. Among the dozens of tests was a couple using smarty, but I think that I forgot the global declaration of $smarty. Thank you 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.