Lorraine1996 Posted May 10, 2020 Share Posted May 10, 2020 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! 0 Quote Link to comment Share on other sites More sharing options...
Lorraine1996 Posted May 11, 2020 Author Share Posted May 11, 2020 No one have a clue? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 11, 2020 Share Posted May 11, 2020 On 10/05/2020 at 01:46, Lorraine1996 said: I would like to create a WHMCS custom page and then include a designated article in this page, is this possible? an article in what sense ? what is the source of the article content ?? 0 Quote Link to comment Share on other sites More sharing options...
Lorraine1996 Posted May 11, 2020 Author Share Posted May 11, 2020 14 minutes ago, brian! said: an article in what sense ? what is the source of the article content ?? Thank you for responding! I would like to include a specified knowledge base article in the customization page so that the article can be edited when content needs to be updated without having to modify the customization page. 0 Quote Link to comment Share on other sites More sharing options...
Lorraine1996 Posted May 11, 2020 Author Share Posted May 11, 2020 56 minutes ago, brian! said: an article in what sense ? what is the source of the article content ?? Specifically, I want to create a TOS page. tos content written in a knowledge base article. The reason for using custom pages is that I can use a better URL for the TOS page and I can easily modify the style of the page. This way, if you need to modify the TOS content in the future, you only need to edit the knowledge base article and not the .tpl file on the customization page. Its ideal workflow would look like this. Custom pages -> corresponding .tpl file -> include a specified knowledge base article 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 12, 2020 Share Posted May 12, 2020 On 11/05/2020 at 13:27, Lorraine1996 said: Specifically, I want to create a TOS page. tos content written in a knowledge base article. the .php would be along the lines of... <?php use WHMCS\ClientArea; use WHMCS\Database\Capsule; define('CLIENTAREA', true); require __DIR__ . '/init.php'; $ca = new ClientArea(); $ca->setPageTitle(Lang::trans('ordertos')); $ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname')); $ca->addToBreadCrumb('tos.php', Lang::trans('ordertos')); $ca->initPage(); $kbarticle = Capsule::table('tblknowledgebase')->where('id','33')->value('article'); $ca->assign('terms', $kbarticle); $ca->setTemplate('tos'); $ca->output(); the '33' is the id value of your kb article that contains your ToS text... and then the tos.tpl template needs to contain {$terms} - that's it! {$terms} you might need to play with additional styling in the template file depending on your site or additional styling needs, but if the .php file finds the specified article, then the text will be displayed in the page... 1 Quote Link to comment Share on other sites More sharing options...
Lorraine1996 Posted May 13, 2020 Author Share Posted May 13, 2020 8 hours ago, brian! said: the .php would be along the lines of... <?php use WHMCS\ClientArea; use WHMCS\Database\Capsule; define('CLIENTAREA', true); require __DIR__ . '/init.php'; $ca = new ClientArea(); $ca->setPageTitle(Lang::trans('ordertos')); $ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname')); $ca->addToBreadCrumb('tos.php', Lang::trans('ordertos')); $ca->initPage(); $kbarticle = Capsule::table('tblknowledgebase')->where('id','33')->value('article'); $ca->assign('terms', $kbarticle); $ca->setTemplate('tos'); $ca->output(); the '33' is the id value of your kb article that contains your ToS text... and then the tos.tpl template needs to contain {$terms} - that's it! {$terms} you might need to play with additional styling in the template file depending on your site or additional styling needs, but if the .php file finds the specified article, then the text will be displayed in the page... Thanks! It worked perfectly! 0 Quote Link to comment Share on other sites More sharing options...
Lorraine1996 Posted May 13, 2020 Author Share Posted May 13, 2020 9 hours ago, brian! said: the .php would be along the lines of... <?php use WHMCS\ClientArea; use WHMCS\Database\Capsule; define('CLIENTAREA', true); require __DIR__ . '/init.php'; $ca = new ClientArea(); $ca->setPageTitle(Lang::trans('ordertos')); $ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname')); $ca->addToBreadCrumb('tos.php', Lang::trans('ordertos')); $ca->initPage(); $kbarticle = Capsule::table('tblknowledgebase')->where('id','33')->value('article'); $ca->assign('terms', $kbarticle); $ca->setTemplate('tos'); $ca->output(); the '33' is the id value of your kb article that contains your ToS text... and then the tos.tpl template needs to contain {$terms} - that's it! {$terms} you might need to play with additional styling in the template file depending on your site or additional styling needs, but if the .php file finds the specified article, then the text will be displayed in the page... A problem was just discovered. If multiple language versions of a knowledge base article exist, it does not seem to be able to display the corresponding version based on the language chosen by the user. May I ask if this problem can be solved? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 13, 2020 Share Posted May 13, 2020 9 hours ago, Lorraine1996 said: A problem was just discovered. If multiple language versions of a knowledge base article exist, it does not seem to be able to display the corresponding version based on the language chosen by the user. and you're intending to make your ToS translated in different languages ? 11 hours ago, Lorraine1996 said: May I ask if this problem can be solved? yes... <?php use WHMCS\ClientArea; use WHMCS\Database\Capsule; define('CLIENTAREA', true); require __DIR__ . '/init.php'; $ca = new ClientArea(); $ca->setPageTitle(Lang::trans('ordertos')); $ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname')); $ca->addToBreadCrumb('tos.php', Lang::trans('ordertos')); $ca->initPage(); $kbarticleid = 38; if ($ca->isLoggedIn()) { $language = Capsule::table('tblclients')->where('id',$ca->getUserID())->value('language'); } else { $language = $_SESSION['Language']; } $kbarticle = Capsule::table('tblknowledgebase')->where('parentid',$kbarticleid)->where('language',$language)->value('article'); if (empty($kbarticle)) { $kbarticle = Capsule::table('tblknowledgebase')->where('id',$kbarticleid)->value('article'); } $ca->assign('terms', $kbarticle); $ca->setTemplate('tos'); $ca->output(); so the way this works now is that the page will try to get the ToS article in the current WHMCS language... if no article exists in the current or chosen language, it will show the default language version. 1 Quote Link to comment Share on other sites More sharing options...
Lorraine1996 Posted May 14, 2020 Author Share Posted May 14, 2020 14 hours ago, brian! said: and you're intending to make your ToS translated in different languages ? yes... <?php use WHMCS\ClientArea; use WHMCS\Database\Capsule; define('CLIENTAREA', true); require __DIR__ . '/init.php'; $ca = new ClientArea(); $ca->setPageTitle(Lang::trans('ordertos')); $ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname')); $ca->addToBreadCrumb('tos.php', Lang::trans('ordertos')); $ca->initPage(); $kbarticleid = 38; if ($ca->isLoggedIn()) { $language = Capsule::table('tblclients')->where('id',$ca->getUserID())->value('language'); } else { $language = $_SESSION['Language']; } $kbarticle = Capsule::table('tblknowledgebase')->where('parentid',$kbarticleid)->where('language',$language)->value('article'); if (empty($kbarticle)) { $kbarticle = Capsule::table('tblknowledgebase')->where('id',$kbarticleid)->value('article'); } $ca->assign('terms', $kbarticle); $ca->setTemplate('tos'); $ca->output(); so the way this works now is that the page will try to get the ToS article in the current WHMCS language... if no article exists in the current or chosen language, it will show the default language version. Fantastic, thank for your answers! 0 Quote Link to comment Share on other sites More sharing options...
Lorraine1996 Posted May 23, 2020 Author Share Posted May 23, 2020 On 5/13/2020 at 9:08 PM, brian! said: and you're intending to make your ToS translated in different languages ? yes... <?php use WHMCS\ClientArea; use WHMCS\Database\Capsule; define('CLIENTAREA', true); require __DIR__ . '/init.php'; $ca = new ClientArea(); $ca->setPageTitle(Lang::trans('ordertos')); $ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname')); $ca->addToBreadCrumb('tos.php', Lang::trans('ordertos')); $ca->initPage(); $kbarticleid = 38; if ($ca->isLoggedIn()) { $language = Capsule::table('tblclients')->where('id',$ca->getUserID())->value('language'); } else { $language = $_SESSION['Language']; } $kbarticle = Capsule::table('tblknowledgebase')->where('parentid',$kbarticleid)->where('language',$language)->value('article'); if (empty($kbarticle)) { $kbarticle = Capsule::table('tblknowledgebase')->where('id',$kbarticleid)->value('article'); } $ca->assign('terms', $kbarticle); $ca->setTemplate('tos'); $ca->output(); so the way this works now is that the page will try to get the ToS article in the current WHMCS language... if no article exists in the current or chosen language, it will show the default language version. May I ask one more question? Is it possible to use the article title as a source for the page title? This way the title of the page also supports multilingualism. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 23, 2020 Share Posted May 23, 2020 5 hours ago, Lorraine1996 said: May I ask one more question? Is it possible to use the article title as a source for the page title? This way the title of the page also supports multilingualism. technically, isn't that two questions?? .... but i'm having a Ask One Get One Free offer this morning, so you're in luck. ☺️ you should only need to tweak the queries a little to get the kb title, and then call the setting of the pagetitle after you have done that... <?php use WHMCS\ClientArea; use WHMCS\Database\Capsule; define('CLIENTAREA', true); require __DIR__ . '/init.php'; $ca = new ClientArea(); $ca->initPage(); $kbarticleid = 38; if ($ca->isLoggedIn()) { $language = Capsule::table('tblclients')->where('id',$ca->getUserID())->value('language'); } else { $language = $_SESSION['Language']; } $kbarticle = Capsule::table('tblknowledgebase')->where('parentid',$kbarticleid)->where('language',$language)->select('title','article')->first(); if (empty($kbarticle)) { $kbarticle = Capsule::table('tblknowledgebase')->where('id',$kbarticleid)->select('title','article')->first(); } $ca->setPageTitle($kbarticle->title); $ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname')); $ca->addToBreadCrumb('tos.php', $kbarticle->title); $ca->assign('terms', $kbarticle->article); $ca->setTemplate('tos'); $ca->output(); 1 Quote Link to comment Share on other sites More sharing options...
Lorraine1996 Posted May 23, 2020 Author Share Posted May 23, 2020 (edited) 3 hours ago, brian! said: technically, isn't that two questions?? .... but i'm having a Ask One Get One Free offer this morning, so you're in luck. ☺️ you should only need to tweak the queries a little to get the kb title, and then call the setting of the pagetitle after you have done that... <?php use WHMCS\ClientArea; use WHMCS\Database\Capsule; define('CLIENTAREA', true); require __DIR__ . '/init.php'; $ca = new ClientArea(); $ca->initPage(); $kbarticleid = 38; if ($ca->isLoggedIn()) { $language = Capsule::table('tblclients')->where('id',$ca->getUserID())->value('language'); } else { $language = $_SESSION['Language']; } $kbarticle = Capsule::table('tblknowledgebase')->where('parentid',$kbarticleid)->where('language',$language)->select('title','article')->first(); if (empty($kbarticle)) { $kbarticle = Capsule::table('tblknowledgebase')->where('id',$kbarticleid)->select('title','article')->first(); } $ca->setPageTitle($kbarticle->title); $ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname')); $ca->addToBreadCrumb('tos.php', $kbarticle->title); $ca->assign('terms', $kbarticle->article); $ca->setTemplate('tos'); $ca->output(); Thank you Brian ! I have discovered an irrelevant problem. If the page requires login to view, the login page will not display the title. Edited May 23, 2020 by Lorraine1996 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.