2016-01-13 50 views
0

我也搜索了所有論壇,甚至我在whmcs論壇發佈我的問題,但沒有迴應。我需要的是,我在模塊中創建了一個插件,我想在此插件的鉤子中更改模板(從六個到五個)。目標是爲特定客戶更改模板。 我已經測試改變GET變種,但不工作:從鉤子更改whmcs模板

$_GET['systpl'] = 'five'; 

我還測試了這一點,但CSS文件不加載。它將我重定向到家:

global $smarty; 
$template = $smarty->getTemplateVars('template'); 
$template = 'six'; 
$smarty->assign('template', $template); 
$template = $smarty->getTemplateVars('template'); 

有什麼建議嗎?

+0

無響應???? – Codinga

回答

2

我已經在我的產品之一這樣做 - 得到這個工作,你必須去拉全球$ systpl變量:

global $systpl; 
$systpl = $tpl; 

$GLOBALS['_SESSION']['Template'] = $tpl; 
$GLOBALS['CONFIG']['Template']  = $tpl; 

其中$第三方物流是你正在尋找設置模板名稱,在你的情況'五'。您還必須在其中設置GLOBALS變量,以便用戶會話與該模板一起維護,以便系統知道在從配置中拉出時使用該模板名稱。

希望有幫助。

+0

非常感謝這項工作,但我如何設置回默認模板? – user467241

+0

我aswer的解決方案: <?php 使用WHMCS \ Database \ Capsule; 使用WHMCS \ View \ Menu \ Item作爲MenuItem; define(「CLIENTAREA」,true); //設置你想用於自定義頁面的模板在調用init.php之前 $ GLOBALS ['_REQUEST'] ['systpl'] ='five'; require(「init.php」); //無論你是在這裏做 //設置會話返回到默認的模板: $ GLOBALS [ '_ SESSION'] [ '模板'] = '六'; $ ca-> output(); – user467241

0

在WHMCS加載另一個模板文件夾指定的頁面,我所做的:

<?php 

use WHMCS\Database\Capsule; 
use WHMCS\View\Menu\Item as MenuItem; 

define("CLIENTAREA", true); 

// Set the template you want to use for the custom page BEFORE init.php is called 
$GLOBALS['_REQUEST']['systpl'] = 'five'; 

require("init.php"); 

// WHATEVER YOU ARE DOING IN HERE 

// Set the session back to the default template: 
$GLOBALS['_SESSION']['Template'] = 'six'; 

$ca->output();