ChrisTERiS Posted February 18, 2021 Share Posted February 18, 2021 Hello all, Does anyone knows if the variable {$WEB_ROOT} is a global variable or not? In some templates it works, in some others not. Also is there any similar variable for PHP files? Currently I'm using my own variables but it gets, without a special reason, an extra query to database. Thank you Chris 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted February 19, 2021 Share Posted February 19, 2021 If you're trying to include another smarty template file, I have just passed a templatefolder variable that puts to __DIR__ . "/templates/" but that has been on server modules . 0 Quote Link to comment Share on other sites More sharing options...
yggdrasil Posted February 19, 2021 Share Posted February 19, 2021 (edited) 19 hours ago, WHMUp said: Hello all, Does anyone knows if the variable {$WEB_ROOT} is a global variable or not? In some templates it works, in some others not. Also is there any similar variable for PHP files? Currently I'm using my own variables but it gets, without a special reason, an extra query to database. Thank you Chris It should be a global variable but since WHMCS has changed so many things and removed code from templates, I'm not surprised if it's not working in some template files. In your smarty file put the following: {debug} Now reload and a new popup will appear (most browsers will block this, don't forget to enable it). Now you can see all the variables available. Don't forget to disable debug after your testing. Edited February 19, 2021 by yggdrasil 1 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted February 19, 2021 Author Share Posted February 19, 2021 1 hour ago, yggdrasil said: It should be a global variable but since WHMCS has changed so many things and removed code from templates, I'm not surprised if it's not working in some template files. In your smarty file put the following: {debug} Now reload and a new popup will appear (most browsers will block this, don't forget to enable it). Now you can see all the variables available. Don't forget to disable debug after your testing. What I hate in Debug which really very useful is that it loads all the language phrases and WHMCS have so many. So, as my visual is not so strong any more, I'm messing my eyes. In any case I'll try to check it. Thank you 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 19, 2021 Share Posted February 19, 2021 On 18/02/2021 at 12:32, WHMUp said: Does anyone knows if the variable {$WEB_ROOT} is a global variable or not? In some templates it works, in some others not. i've seen it appear as both {$WEB-ROOT} and {$webroot} in some templates... 🙄 On 18/02/2021 at 12:32, WHMUp said: Also is there any similar variable for PHP files? Currently I'm using my own variables but it gets, without a special reason, an extra query to database. you can create the variable in PHP hooks etc using... $assetHelper = DI::make("asset"); $webroot = $assetHelper->getWebRoot(); ... and then either use that variable in your hook, or return it to the template if you need to guarantee that the variable will exist in the template. 1 Quote Link to comment Share on other sites More sharing options...
yggdrasil Posted February 20, 2021 Share Posted February 20, 2021 11 hours ago, brian! said: i've seen it appear as both {$WEB-ROOT} and {$webroot} in some templates... 🙄 you can create the variable in PHP hooks etc using... $assetHelper = DI::make("asset"); $webroot = $assetHelper->getWebRoot(); ... and then either use that variable in your hook, or return it to the template if you need to guarantee that the variable will exist in the template. That seems a rather weird coding approach, instead of consistency, using different variables that sound and look similar but are not and still do the same thing. 1 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 20, 2021 Share Posted February 20, 2021 7 hours ago, yggdrasil said: That seems a rather weird coding approach, instead of consistency, using different variables that sound and look similar but are not and still do the same thing. welcome to WHMCS - I didn't write that! 😉 0 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted February 23, 2021 Author Share Posted February 23, 2021 Finally I prefer to keep my own way. Maybe I add one more query to database but I've globally available, some important values. 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.