Jump to content

How to create a page just for promotions


Recommended Posts

Hi All,

 

I was wondering if it was possible for me to create a page for promotions for my customers. For instance all my customers are willing to give discount etc for other customers. I was wondering if i can set a page just for logged in clients to view what promotions/offers are available?

 

Is this possible or am i barking up the wrong tree.

Link to comment
Share on other sites

to expand on @Vox reply, you could do this in the .php file...

if ($ca->isLoggedIn()) {
	$ca->setTemplate('clientareahome');
} else {
	$ca->setTemplate('homepage');
}
$ca->output();

so logged in users would see clientareahome, anyone not logged in would see homepage... obviously, you wouldn't use these two templates, but you get the idea. :smile:

alternatively, you could point to just one template and let the template handle what to do whether they're logged in or not.

btw - if you were feeling lazy and didn't want to use a new custom page, another way might be to make a kb article and mark it private - only logged in clients would be able to read it... and you could link to it directly if required.

Link to comment
Share on other sites

1 hour ago, monsterit said:

Ok, so if i did a standard php page that would work, but what hooks do i add in?

you shouldn't necessarily need any hooks... if you don't need sidebars, specific variables etc, at the most basic, you can use the code in the thread below...

<?php
use WHMCS\ClientArea;
define('CLIENTAREA', true);
require __DIR__ . '/init.php';
$ca = new ClientArea();
$ca->setPageTitle('Current Promotions');
$ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname'));
$ca->addToBreadCrumb('kyle.php', 'Current Promotions');
$ca->initPage();
$ca->setTemplate('promotions');
$ca->output();

and then in the promotions.tpl template...

{if $loggedin}
here are a list of current promotions
{else}
you need to <a href="login.php">Login</a> to view this page.
{/if}

or if you want to redirect guests (non logged in users) to the login page...

{if !$loggedin}
<script type="text/javascript">
    window.location.replace("login.php");
</script>
{else}
here are a list of current promotions
{/if}

r5eZGr1.png

another way, and probably the better method, would be to require login in the php file itself...

<?php
use WHMCS\ClientArea;
define('CLIENTAREA', true);
require __DIR__ . '/init.php';
$ca = new ClientArea();
$ca->setPageTitle('Current Promotions');
$ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname'));
$ca->addToBreadCrumb('kyle.php', 'Current Promotions');
$ca->requireLogin();
$ca->initPage();
$ca->setTemplate('promotions');
$ca->output();

and then the template no longer needs to check if the user is logged in (though it could for added security if you want to)...

once upon a time...

qlueOTf.png

1 hour ago, monsterit said:

as the article is not very self explanatory.

a lot of the documentation isn't fit for purpose... it doesn't include all the options available (and with encrypted software, how else are we supposed to know?), and some of the examples are vague/wrong/confusing for new users...

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