I would like to create a WHMCS custom page and then include a designated article in this page, is this possible?
I've created custom pages by official documents, but I don't know how to include articles.
Any help, thanks in advance!
tblknowledgebase , tblknowledgebasecats , tblknowledgebaselinks , tblknowledgebasetags
.your Template :
<!-- 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}
Your Page :
<?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();
?>