Jump to content

How do you pass back module custom function responds to client area?


andy3dfx

Recommended Posts

function template_reboot($params) {

 

# Code to perform action goes here...

 

if ($successful) {

$result = "success";

} else {

$result = "Error Message Goes Here...";

}

return $result;

}

 

This example code above. I can see the $result message passed back into admin area page. But how do you pass back the $result into client area?

I can see the smarty template var {$moduleclientarea}. This is where to display client codes.

 

So how to show custom responds $result into {$moduleclientarea} ?

 

Thank you for the help.

Link to comment
Share on other sites

Custom admin buttons (like the reboot example) are not in the client area. You'd want to look at the _ClientArea() function.

 

I understand. Let's say I call the custom function reboot in clientarea like

 

function template_ClientArea($params) {

 

$code = '<form action="clientarea.php?action=productdetails" method="post" >

<input type="hidden" name="id" value="'.$params["serviceid"].'" />

<input type="hidden" name="modop" value="custom" />

<input type="hidden" name="a" value="reboot" />

<input name="user" size="20" type="reboot" />

<input type="submit" value="test" />

</form>';

return $code;

}

 

How do you display the $result from the custom reboot function in clieantarea?

 

I tried with $code .= $result. It didn't work.

 

If I do echo $result; in reboot function. It will display on top of clientarea before the <HTML> code which isn't right.

Link to comment
Share on other sites

It would probably be easier to do the processing for that within the ClientArea() function. You might be able to assign some smarty vars to the output within the reboot function. Something like this:

 

global $smarty;

$result = "blah blah blah";
$smarty->assign("results", $result);

 

Then add something like this within your $code in ClientArea():

 

<div class="errorbox">{$results}</div>

Link to comment
Share on other sites

Thank You laszlof. I found the solution.

 

That was my original thought, to do processing in clientarea() code. But the function will get ridiculously long and defeat the purpose of having custom function ability. Plus, the code will lose it is modularity as well.

 

Here is easy solution. the WHMCS has smarty var for custom function output. Just put

{$modulecustombuttonresult} in clientareaproductdetails.tpl.

 

Credit to Matt in WHMCS

Link to comment
Share on other sites

  • 2 years later...

I've been trying to do either solution (the one provided by laszlof and the one suggested by Matt from WHMCS) and know that i'm overlooking something...

 

Here is what I have which is not working in my HC.php file:

function HC_reboot($params) {

# Code to perform reboot action goes here...

global $smarty;

   	if ($successful) {
	$result = "success";
} else {
	$result = "Error Message Goes Here...";
}

$smarty->assign("results", $result);

return $result;
}

function HC_ClientArea($params) {

$results = "not set yet.";

$code = '<div class="errorbox">{$results}</div>
<form action="clientarea.php?action=productdetails" method="post" >
<input type="hidden" name="id" value="'.$params["serviceid"].'" />
<input type="hidden" name="modop" value="custom" />
<input type="hidden" name="a" value="reboot" />
<input name="user" size="20" type="reboot" />
<input type="submit" value="test1" />
</form>';

return $code;

}

Link to comment
Share on other sites

  • 5 months later...

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