如何在 WHMCS 自定义页面中包含文章?
How to include an articles in the WHMCS custom page?
我想创建一个 WHMCS 自定义页面,然后在此页面中包含指定的文章,这可以吗?
我已经通过 official documents 创建了自定义页面,但我不知道如何包含文章。
任何帮助,提前致谢!
- 您必须在 :
tblknowledgebase , tblknowledgebasecats , tblknowledgebaselinks , tblknowledgebasetags
.
- 参见:https://developers.whmcs.com/advanced/db-interaction/
您的模板:
<!-- C:\xampp\htdocs\my\templates\redo\my_page.tpl-->
{foreach $arr as $elem}
<div>{$elem.title}</div>
<div>{$elem.article}</div>
<div>{$elem.views}</div>
{/foreach}
您的专页:
<?php
// file : ROOTDIR / my_page.php
use WHMCS\ClientArea;
use WHMCS\Database\Capsule;
define('CLIENTAREA', true);
require_once __DIR__ . '/init.php';
require_once(ROOTDIR . '/includes/dbfunctions.php');
//require_once(ROOTDIR . '/includes/functions.php');
//require_once(ROOTDIR . '/includes/clientfunctions.php');
//require_once(ROOTDIR . '/includes/modulefunctions.php');
$ca = new ClientArea();
$ca->setPageTitle('My Page');
$ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname'));
$ca->addToBreadCrumb('my_page.php', 'This is my page');
$ca->initPage();
//$ca->requireLogin(); // Uncomment this line to require a login to access this page
// To assign variables to the template system use the following syntax.
// These can then be referenced using {$variablename} in the template.
$knowledgebase=array();
//https://developers.whmcs.com/advanced/db-interaction/
//$res=select_query('tblknowledgebase','*',array());
$res=full_query('SELECT * FROM tblknowledgebase');
while($data=mysql_fetch_array($res))
{
$knowledgebase[]=$data;
var_dump($data);
}
// You must write
//tblknowledgebase , tblknowledgebasecats , tblknowledgebaselinks , tblknowledgebasetags
file_put_contents("C:/xampp/htdocs/my_website/sss.txt",var_export($knowledgebase,true),FILE_APPEND);
$ca->assign('arr', $knowledgebase); // $arr will be used in template.
$ca->assign('pagetype',redo);
// Check login status
//Menu::addContext();
$ca->setTemplate('my_page'); // without .tpl
$ca->output();
?>
我想创建一个 WHMCS 自定义页面,然后在此页面中包含指定的文章,这可以吗?
我已经通过 official documents 创建了自定义页面,但我不知道如何包含文章。
任何帮助,提前致谢!
- 您必须在 :
tblknowledgebase , tblknowledgebasecats , tblknowledgebaselinks , tblknowledgebasetags
. - 参见:https://developers.whmcs.com/advanced/db-interaction/
您的模板:
<!-- C:\xampp\htdocs\my\templates\redo\my_page.tpl-->
{foreach $arr as $elem}
<div>{$elem.title}</div>
<div>{$elem.article}</div>
<div>{$elem.views}</div>
{/foreach}
您的专页:
<?php
// file : ROOTDIR / my_page.php
use WHMCS\ClientArea;
use WHMCS\Database\Capsule;
define('CLIENTAREA', true);
require_once __DIR__ . '/init.php';
require_once(ROOTDIR . '/includes/dbfunctions.php');
//require_once(ROOTDIR . '/includes/functions.php');
//require_once(ROOTDIR . '/includes/clientfunctions.php');
//require_once(ROOTDIR . '/includes/modulefunctions.php');
$ca = new ClientArea();
$ca->setPageTitle('My Page');
$ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname'));
$ca->addToBreadCrumb('my_page.php', 'This is my page');
$ca->initPage();
//$ca->requireLogin(); // Uncomment this line to require a login to access this page
// To assign variables to the template system use the following syntax.
// These can then be referenced using {$variablename} in the template.
$knowledgebase=array();
//https://developers.whmcs.com/advanced/db-interaction/
//$res=select_query('tblknowledgebase','*',array());
$res=full_query('SELECT * FROM tblknowledgebase');
while($data=mysql_fetch_array($res))
{
$knowledgebase[]=$data;
var_dump($data);
}
// You must write
//tblknowledgebase , tblknowledgebasecats , tblknowledgebaselinks , tblknowledgebasetags
file_put_contents("C:/xampp/htdocs/my_website/sss.txt",var_export($knowledgebase,true),FILE_APPEND);
$ca->assign('arr', $knowledgebase); // $arr will be used in template.
$ca->assign('pagetype',redo);
// Check login status
//Menu::addContext();
$ca->setTemplate('my_page'); // without .tpl
$ca->output();
?>