Jump to content

[php] in header.tpl


DataHosts

Recommended Posts

Ok...I am at a loss here as I have tried everything, but to no success. I am trying to include a PHP file to be called on each page of WHMCS. I have review Smarty, the forum, and even googled.....but each time I try it does not work. I have tried the following:

 

File located outside WHMCS directory:
{php}
include "http://www.domain.com/include/file.php";
{/php}

 

File located outside WHMCS directory:
{php}
include "http://whmcs.domain.com/templates/{tempate}/file.php";
{/php}

 

Path:
{php}
include_file="/home/{uname}/public_html/whmcs/file.php";
{/php}

 

Path:
{php}
include_file='/home/{uname}/public_html/whmcs/file.php';
{/php}

 

 

Now I am just banging my head and I am tired. So, any assitance would be great as I know I am overlooking the obvious...but another set of eyes (brains) is better than 1 anyday.

Link to comment
Share on other sites

Forget about the {php}...{/php} tags. (Smarty try to discourage its use)

Try

{* for absolute filepath *}

{include file='/usr/local/include/templates/header.tpl'}

 

{* for absolute filepath (same thing) *}

{include file='file:/usr/local/include/templates/header.tpl'}

 

{* for windows absolute filepath (MUST use "file:" prefix) *}

{include file='file:C:/www/pub/templates/header.tpl'}

 

{* for include from template resource named "db" *}

{include file='db:header.tpl'}

 

{* for include a $variable template - eg $module = 'contacts' *}

{include file="$module.tpl"}

 

{* wont work as its single quotes ie no variable substitution *}

{include file='$module.tpl'}

 

{* for include a multi $variable template - eg amber/links.view.tpl *}

{include file="$style_dir/$module.$view.tpl"}

Link to comment
Share on other sites

  • 4 weeks later...

OK in a straight php file its a little different

here is an example of some code that I use for an include

eg..

The main php file is in the admin directory

so this line tells where the file is to include (relative to the directory that the script started in (admin) it goes back 1 directory then into the modules/admin/template_editor directory

$configfile = '../modules/admin/template_editor/teconfig.php';
Now the include

If the file exists then include it

if (file_exists($configfile)) include($configfile);
If you don't want to check if the file exists use
include($configfile);
I hope that helps you

Cheers

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