Jump to content

Custom Page Issue


Tom Wilson

Recommended Posts

Hi guys,

Pretty sure I am doing something so simple and I can't get my head around it...

I am wanting to create a custom page - this is what I have in in the 'root' directory.

'legal.php'

<?php

use WHMCS\ClientArea;
use WHMCS\Database\Capsule;

define('CLIENTAREA', true);

require __DIR__ . '/init.php';

$ca = new ClientArea();

$ca->setPageTitle('Your Page Title Goes Here');

$ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname'));
$ca->addToBreadCrumb('legal.php', 'Legal');

$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.

//$ca->assign('variablename', $value);

// Check login status
if ($ca->isLoggedIn()) {

    /**
     * User is logged in - put any code you like here
     *
     * Here's an example to get the currently logged in clients first name
     */

    $clientName = Capsule::table('tblclients')
        ->where('id', '=', $ca->getUserID())->pluck('firstname');
        // 'pluck' was renamed within WHMCS 7.0.  Replace it with 'value' instead.
        // ->where('id', '=', $ca->getUserID())->value('firstname');
    $ca->assign('clientname', $clientName);

} else {

    // User is not logged in
    $ca->assign('clientname', 'Random User');

}

/**
 * Set a context for sidebars
 *
 * @link http://docs.whmcs.com/Editing_Client_Area_Menus#Context
 */
Menu::addContext();

/**
 * Setup the primary and secondary sidebars
 *
 * @link http://docs.whmcs.com/Editing_Client_Area_Menus#Context
 */
Menu::primarySidebar('announcementList');
Menu::secondarySidebar('announcementList');

# Define the template filename to be used without the .tpl extension

$ca->setTemplate('legal');

$ca->output();

and in 'templates/magic/legal.tpl'

<p>test</p>

Any ideas?

Link to comment
Share on other sites

Hi @Tom Wilson,

try :

<?php
 
 define("CLIENTAREA",true);
 //define("FORCESSL",true); // Uncomment to force the page to use https://
 
 require("init.php");
 
 $ca = new WHMCS_ClientArea();
 
 $ca->setPageTitle("Legal");
 
 $ca->addToBreadCrumb('index.php','Home');
 $ca->addToBreadCrumb('legal.php','Legal');
 
 $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.
 
 $ca->assign('pagetype', custom);
 $ca->assign('category', legal);

 # Check login status
 if ($ca->isLoggedIn()) {
 
   # User is logged in - put any code you like here
 
   # Here's an example to get the currently logged in clients first name
 
   $result = mysql_query("SELECT firstname FROM tblclients WHERE id=".$ca->getUserID());
   $data = mysql_fetch_array($result);
   $clientname = $data[0];
 
   $ca->assign('clientname', $clientname);
 
 } else {
 
   # User is not logged in
 
 }
 
 # Define the template filename to be used without the .tpl extension
 
 $ca->setTemplate('legal');
 
 $ca->output();
 
 ?>

Greetings Christian

Link to comment
Share on other sites

36 minutes ago, wp4all said:

Hi @Tom Wilson,

try :


<?php
 
 define("CLIENTAREA",true);
 //define("FORCESSL",true); // Uncomment to force the page to use https://
 
 require("init.php");
 
 $ca = new WHMCS_ClientArea();
 
 $ca->setPageTitle("Legal");
 
 $ca->addToBreadCrumb('index.php','Home');
 $ca->addToBreadCrumb('legal.php','Legal');
 
 $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.
 
 $ca->assign('pagetype', custom);
 $ca->assign('category', legal);

 # Check login status
 if ($ca->isLoggedIn()) {
 
   # User is logged in - put any code you like here
 
   # Here's an example to get the currently logged in clients first name
 
   $result = mysql_query("SELECT firstname FROM tblclients WHERE id=".$ca->getUserID());
   $data = mysql_fetch_array($result);
   $clientname = $data[0];
 
   $ca->assign('clientname', $clientname);
 
 } else {
 
   # User is not logged in
 
 }
 
 # Define the template filename to be used without the .tpl extension
 
 $ca->setTemplate('legal');
 
 $ca->output();
 
 ?>

Greetings Christian

That worked. Thank you!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated