Jump to content

Banner in WHMCS email templates


Recommended Posts

have wrote the banner ad script for PHP7 i want to show a random banner ad in each email sent out by my whmcs but im not the very best tool in the shop when it comes to smartty php.

 

All the codes i have seen and stuff i tried just shooting in the dark don't work.

 

Can anybody help me with what line i would need to add in my email templates to make this work.

 

Thanks In Advance.

Link to comment
Share on other sites

it's difficult to give specific advice without seeing what the PHP code is doing, but if you wanted a pure Smarty solution (without the need for additional PHP coding), then you could add the following to one of your email templates...

 

{$images = ['com.png','couk.png']} {assign randomindex value=$images|@array_rand} <img title="Random Image" src="http://www.domain.com/whmcs/assets/img/tld_logos/{$images.$randomindex}" alt="Random Image" border="0" />

assuming the image exists, and the path is correct, then the above should output a random image, from the array of image filenames, to the email. :idea:

 

the important point to remember with this is that by default, you cannot use array_rand in your email templates with WHMCS v7 - you will need to modify your Smarty Security Policy to add array_rand to your modifiers array within configuration.php...

 

// Smarty custom email based template policy:
$smarty_security_policy = array(
   'mail' => array(
       'php_functions' => array(
           'strstr',
       ),
       'php_modifiers' => array(
           'array_rand',
       ),
   ),
   'system' => array(
       'trusted_dir' => array(
           '/templates/six',
       ),
   ),
);

 

CryFkN8.png

Link to comment
Share on other sites

it's difficult to give specific advice without seeing what the PHP code is doing, but if you wanted a pure Smarty solution (without the need for additional PHP coding), then you could add the following to one of your email templates...

 

{$images = ['com.png','couk.png']} {assign randomindex value=$images|@array_rand} <img title="Random Image" src="http://www.domain.com/whmcs/assets/img/tld_logos/{$images.$randomindex}" alt="Random Image" border="0" />

assuming the image exists, and the path is correct, then the above should output a random image, from the array of image filenames, to the email. :idea:

 

the important point to remember with this is that by default, you cannot use array_rand in your email templates with WHMCS v7 - you will need to modify your Smarty Security Policy to add array_rand to your modifiers array within configuration.php...

 

// Smarty custom email based template policy:
$smarty_security_policy = array(
   'mail' => array(
       'php_functions' => array(
           'strstr',
       ),
       'php_modifiers' => array(
           'array_rand',
       ),
   ),
   'system' => array(
       'trusted_dir' => array(
           '/templates/six',
       ),
   ),
);

 

CryFkN8.png

 

 

 

here is what i have tried doing to call to the banner script..

i have tried doing a simple include

<center>

<? include("banners.php"); ?>

</center>

 

That dont work at all its like i never put the code in the template. I also tried doing a iframe

<iframe src="https://www.easttexasbusinesssolutions.com/advertising/banners.php" height="500" width="480" border="0" scrolling="no"></iframe>

 

on the backend where you edit the template it will pull the iframe but not the banners. I made a test account to see if it would pass the iframe off in the client email and it dont show the iframe in the welcome email even though it shows it in the backend where i put it in the welcome email template

Link to comment
Share on other sites

  • 2 weeks later...
here is what i have tried doing to call to the banner script..

i have tried doing a simple include

<center>

<? include("banners.php"); ?>

</center>

 

That dont work at all its like i never put the code in the template.

as a quick fix, you could wrap your code in the email template with {php}{/php} to see if it works, but that's definitely not a long-term solution.

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