简体   繁体   中英

WHMCS PHP Include

I am trying to include analytic.php into head.tpl in WHMCS but it keep giving me a error.

Analytic.php location: root/analytic.php

Head.tpl location: root/whmcs/template/six/includes/head.tpl

I saw on google, WHMCS accept smarty PHP, so i am trying to include with Smarty PHP Code in head.tpl .

Code:

{include_php file="../../../../analytic.php"};

Also Tried:

{php}{include_php file="../../../../analytic.php"};{/php}

Note: I have already enabled Smarty PHP in WHMCS

But when i am entering the code, the WHMCS site get stop working:(. What the solution to include PHP file inside WHMCS or .tpl file?

include_php is depreced as of Smarty 3.1. {php}NO.{include_php file="../../../../analytic;php"};NO!{/php} is totally wrong.

you should create 'analytics.tpl' file and then include it {include} , file can contain analytics script.

To include a file in WHMCS do

{include file="analytic.tpl"}

Inside your analytic.tpl you can use PHP with

{php}
echo "works";
{/php}

You also must activate this function inside your WHMCS Admin Area.

  • Navigate to: "System Settings - General Settings".
  • Switch to Tab "Security".
  • Search for "Allow Smarty PHP Tags" and activate it.

You should consider to move to hooks instead of PHP-Code inside your templates: https://developers.whmcs.com/themes/php/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM