Jump to content

WHMCS 6 Upgrade: Converting a multi-dimensional $this->_tpl_vars to the new parameter $template->get


pdstein

Recommended Posts

I encountered a problem when I upgraded WHMCS 5 to WHMCS 6 on one of my custom templates.

 

One of the template migration instructions for PHP blocks as stated HERE is below:

 

EXAMPLE:

 

{php}

// Retrieve a single template variable. 
$myValue = $this->_tpl_vars['myVariable'];

// Loop through all template variables.
foreach ($this->_tpl_vars as $key => $value) {
  echo "{$key}: {$value}";
}

// Assign a new template variable.
$this->assign('myNewVariable', 'myNewValue');

{/php}

 

Converts to:

 

{php}

// Retrieve a single template variable. 
$myValue = $template->getVariable('myVariable')->value;

// Loop through all template variables. 
foreach ($template->getTemplateVars() as $key => $variable) {
  echo "{$key}: {$variable->value}";
}

// The assign() method works as it did before, though it must now be 
// called on the $template object instead of $this.
$template->assign('myNewVariable', 'myNewValue');

{/php}

 

Now the problem is this. How will I convert a multi-dimensional $this->_tpl_vars ? Or to be more specific, how will I convert a code that looks like this:

 

$email = $this->_tpl_vars['clientsdetails']['email'];

 

I was looking at the new $client Object, but not sure how to use it either and how to retrieve the email info from it.

 

Hope anybody can help me. Thanks!

Link to comment
Share on other sites

  • 3 weeks 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