Jump to content

WEB_ROOT variable in templates


ChrisTERiS

Recommended Posts

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

Link to comment
Share on other sites

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 by yggdrasil
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated