Jump to content

WHMCS 7 setTemplate()?


Recommended Posts

Hello,

 

We just upgraded from WHMCS 5 to 7 and one of our custom pages no longer works.

 

<?php
define("CLIENTAREA",true);
require("init.php");
$ca = new WHMCS_ClientArea();
$ca->setPageTitle("PAGE TITLE");
$ca->initPage();
$ca->requireLogin();
$ca->setTemplate('TEMPLATENAME');
$ca->output();
?>

 

We correctly upload the TEMPLATENAME.tpl file to the /templates/six directory and, even with a simple .tpl file :

 

{php}
exit("!!!");
{/php}

 

Only the header and footer are displayed on the page. Why?

 

Thanks.

Link to comment
Share on other sites

Thanks for your input. It turns out that it works if the .tpl file contains only the HTML to output, but it doesn't work with the {php} tags and echo(). Not sure what changed here.

a lot.

 

the option to use {php} got disabled by default with v6.

 

http://docs.whmcs.com/Version_6_Template_Migration_Guide

 

An option was added to WHMCS 6 to enable use of the potentially dangerous {php} tag in custom templates. This option is disabled by default but can be enabled if required in Setup > General Settings > Security. We strongly encourage using hook functions over php code blocks inside of templates for backend interaction.

i'd be surprised if the {php} option is still available when WHMCS launch v8 - so in the short term, you can still enable the option; in the long-term, get out of the habit of using it. :idea:

Link to comment
Share on other sites

"However, as of Smarty 3, support for the {php} block has been removed [...]".

https://developers.whmcs.com/themes/php/

in the short-term, if you need to enable {php} tags you can do so via the General Settings...

 

http://docs.whmcs.com/Security_Tab#Allow_Smarty_PHP_Tags

 

The use of {php} tags is depreciated in WHMCS v6 and above, but legacy support can be enabled here during a transition period. We recommend keeping this option disabled unless specifically required. For more information refer to Templates and Custom PHP Logic.

... but you should be looking to move them to use other solutions, such as action hooks.

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