Jump to content

accessing variables


Emhope

Recommended Posts

I am having an issue finding how to utilise variables that don't appear to be accessible in certain template files.

 

eg. $registerdomainenabled is available on homepage.tpl but not available elsewhere.

 

Is there an easy way to retrieve and/or set the status of this variable (true or false) on other template files?

Link to comment
Share on other sites

the usual way would be to use Action Hooks - http://docs.whmcs.com/Hooks - the required information can usually be found by accessing existing variables or querying the database...

 

e.g., if you wanted to make the value of $registerdomainenabled available on other client pages, you could use the hook below... equally, you could query the db for the same information.

 

<?php

function register_enabled_hook($vars) 
{
   global $CONFIG;
   $registerenabled = $CONFIG['AllowRegister']; 

   if ($registerenabled == "on") {
       $registerenabled = TRUE;
       return array("registerenabled" => $registerenabled);
   }
}
add_hook("ClientAreaPage", 1, "register_enabled_hook");
?> 

in practice, the above creates a new variable, $registerenabled, if the "Allow Clients to Register domains" checkbox is ticked in the settings.

 

DyPLMAm.png

 

if it's unticked, then this new variable will not be created - thus working in exactly the same way as $registerdomainenabled.

 

if you wanted to, you could tweak the hook code to call it $registerdomainenabled and replace the existing variable - but as things stand, on the homepage, you should have access to both variables; on other pages, you should only have access to this new one.

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