Jump to content

Overriding System Set Variables


growe

Recommended Posts

In the .php file associated with a given page I am able to but this code...

$smarty->assign('pagetitle', 'New Page Title');

 

Doing so resets the value of {$pagetitle} that WHMCS set and changes it to what I would like. I know there are easier ways to do it but it works great when combined with a bunch of if() statements. The page name can be set on the fly. I am currently only using this method for custom pages I have created.

 

My question is this... Where do I put the PHP code for changes I need to make system wide?

I now have a need to change some other variables that are not specific to one page. I would like the variable changed system wide. The changes also need to be embedded in if() statements.

 

Example

if($criteria=="Something")
{
    $smarty->assign('companyname', 'Company A');
}
elseif($criteria=="Something Else")
{
    $smarty->assign('companyname', 'Company B');
}
else
{
    $smarty->assign('companyname', 'Company C');
}

 

Where do I put the above code?

Edited by growe
Link to comment
Share on other sites

I just answered my own question...

 

I created a .php file in /includes/hooks with the following code:

<?php
if (!defined("WHMCS"))
die("This file cannot be accessed directly");

function edit_ClientArea_Variables($vars) {

global $smarty;

if($criteria=="Something")
{
	    $smarty->assign('companyname', 'Company A');
}
elseif($criteria=="Something Else")
{
     $smarty->assign('companyname', 'Company B');
}
else
{
     $smarty->assign('companyname', 'Company C');
}  
}

add_hook("ClientAreaPage",1,"edit_ClientArea_Variables");

?>

Edited by growe
Link to comment
Share on other sites

If we had some creative hooks similar to the one above, we could also change the template by using

?systpl=

.

What would be real slick is a hook that could change the image that the system uses for invoices etc.

 

By changing the company name (as shown in the earlier post in this thread), changing the template (as shown in the above code) and finding away to change the logo in the invoices, etc. It wouldn't be hard to have several virtual companies based on some criteria such as what domain name the user accessed.

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