Jump to content

Custom page links when using a provisioning module with a Product Addon


websavers

Recommended Posts

Curious to see if anyone else has tried using the new provisioning module capabilities associated with a product addon (not a product).

The standard provisioning actions like create/terminate are working just fine. But I'm trying to create a button that opens a custom page with a custom page template and I can't seem to get the code right -- it always just loads the product's page rather than my custom page. Here's the relevant code:

function module_domainreports(array $params){
  return array(
    'pagetitle' => 'Domain Reports',
    'templatefile' => 'domainreports',
    'vars' => array(
        'test1' => 'hello',
        'test2' => 'world',
    ),
  );
}

function module_ClientAreaAllowedFunctions() {
	return array(
    "Domain Reports" => "domainreports",
  );
}

function module_ClientArea(array $params) {
  return '
  <form method="get" action="clientarea.php">
    <input type="hidden" name="action" value="productdetails" />
    <input type="hidden" name="id" value="' . $params['serviceid'] . '" />
    <input type="hidden" name="modop" value="custom" />
    <input type="hidden" name="a" value="domainreports" />
    <button type="submit">View Reports</button>
  </form>';
}

I do have a domainreports.tpl file in my module dir. It's got a single line of text in it.

Am I simply doing it wrong?

Edited by jas8522
Link to comment
Share on other sites

Hi, 

 

In the client area, if you need to show a custom templates depending on the area where you are, you'll need to return an array with the new tamplates files.

 

EX : 

function module_ClientArea(array $params) {

	// Get the template file, the $_REQUEST can be set in your default template to change sections
	$Template_Area = isset($_REQUEST['template_area']) ? $_REQUEST['template_area'] : '';

	// Select the templates files depending on the requested area
	if ($Template_Area == 'cool_place') {
		$Template_File = 'templates/cool_place.tpl';
	} else {
		$Template_File = 'templates/overview.tpl';
	}

    // Return the template file to be used when loading the client area. 
    return array('tabOverviewReplacementTemplate' => $Template_File);
}

 

In your default template (the one called "overview.tpl" in this example) you just need to place a simple button this switch from one area to the other :

<form method="post" action="clientarea.php?action=productdetails">
  <input type="hidden" name="id" value="{$serviceid}" />
  <input type="hidden" name="template_area" value="cool_place" />
  <button class="btn btn-default">
  	{$LANG.module.Go_To_Cool_Place_Button}
  </button>
</form>

 

You can find an example on the WHMCS github provision module code example.

 

Hope this help!

 

Link to comment
Share on other sites

  • 1 month later...
On 2018-01-25 at 8:27 AM, Neutrall said:

Hi, 

 

In the client area, if you need to show a custom templates depending on the area where you are, you'll need to return an array with the new tamplates files.

 

EX : 


function module_ClientArea(array $params) {

	// Get the template file, the $_REQUEST can be set in your default template to change sections
	$Template_Area = isset($_REQUEST['template_area']) ? $_REQUEST['template_area'] : '';

	// Select the templates files depending on the requested area
	if ($Template_Area == 'cool_place') {
		$Template_File = 'templates/cool_place.tpl';
	} else {
		$Template_File = 'templates/overview.tpl';
	}

    // Return the template file to be used when loading the client area. 
    return array('tabOverviewReplacementTemplate' => $Template_File);
}

 

In your default template (the one called "overview.tpl" in this example) you just need to place a simple button this switch from one area to the other :


<form method="post" action="clientarea.php?action=productdetails">
  <input type="hidden" name="id" value="{$serviceid}" />
  <input type="hidden" name="template_area" value="cool_place" />
  <button class="btn btn-default">
  	{$LANG.module.Go_To_Cool_Place_Button}
  </button>
</form>

 

You can find an example on the WHMCS github provision module code example.

 

Hope this help!

And this has worked for you when using a server module attached to a product addon?

I ask because I'm doing it in this manner now and it only ever redirects me to the productdetails page without loading my custom template. I suspect that since the addon doesn't represent the entire product, it doesn't have the capability to override the template.

 

Edited by jas8522
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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