Script Tips


Wednesday, 15 February 2012 06:24

WHMCS Template viewer

Written by 
Rate this item
(0 votes)

How to view your WHMCS Template before you upload it

WHMCS uses Smarty templates which can be setup on your PC to view your changes before you upload them.
Of course there are some linits as the variables must be set for each page which make it a bit of a task.

But if all you want to do is edit the header and footer then I have done the work for you.

Create a index.php file and add the following to it.

<?php
 // put full path to Smarty.class.php
require('libs/Smarty.class.php');
$smarty = new Smarty();

$smarty->assign('companyname',your title here');  //<<-- Your Company Title
$smarty->assign('systemurl','http://localhost/');  //<<-- place the url here
$smarty->setTemplateDir('templates/default');  //<<-- this and the next two must match exact your folder names.
$smarty->setCompileDir('templates_c');
$smarty->setCacheDir('cache');

$smarty->assign('template','default');  //<<- Set it to template folder name and do not change anything below this.
$smarty->assign('charset','utf-8');
$smarty->assign('LANG' , array('hometitle'=>'Home','announcementstitle'=>'Announcements',
                               'knowledgebasetitle'=>'Knowledgebase',
                                'networkstatustitle'=>'Network Status',
                                'affiliatestitle' => 'affiliatestitle','contactus'=>'Contact Us',
                                 'account'=>'Account','login' =>'Login', 'register'=> 'Register',
                                  'forgotpw'=> 'Forgot Password?'));

$smarty->debugging = false;
$smarty->caching = false;
$smarty->cache_lifetime = 120;

 $smarty->display('header.tpl');
$smarty->display('footer.tpl');
?>

That's all you need - now download Smarty 3.x1.7 and copy your WHMCS template folder including all files in it and the includes/jscript folder to your PC

create a directory structure under your web folder as follows

/lib
/includes/jscript
/cache
/templates
/templates_c

That's it - you should be able to view the header and footer as it will look on your site in WHMCS.
There was one problem I had which was the menu didn't work under this proper. For some reason the background color didn't show on the default template and the drop down menu didn't work. This could be due to WHMCS using an older version of Smarty. ( ver 2.6.26)

But you really don't need those to work since they should be changed.
You can set the debug or the cache on if you wish but it's best to leave the cache off for development since you will need to view changes. Having the cache on will require you to erase the cache files in order to see changes made.

Have fun

Read 3801 times Last modified on Sunday, 26 April 2015 00:07

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.

 

 

Script Tips Search

Registered User