Once you have created a custom page in WHMCS you may want to define SEO data for it. The SEO data includes a page title, meta description and meta tags although it is possible to add any meta data you like. In this tutorial you'll learn how to add this functionality to any pages you create.
Targeting Pages
In order to assign data to a page we must first find a way to target it. Within WHMCS there are two pre-defined variables that we can use to detect which page the user is on. They are:
$filename - This variable is the name of the PHP filename used by the page. e.g company.php = company
$templatefile - This variable is the name of the TPL filename used by the page. e.g company.tpl = company
If you're unsure which values are used you can paste the following temporarily to the bottom of footer.tpl. Load the page you'd like to target and you'll see the values to use for step 2:
Filename: {$filename}
Templatefile: {$templatefile}
Adding SEO Data To A Custom Page
Keeping note of the way we can target a page let's say for example you create a page named custom.php and want to assign SEO data to it.
Open the following file (contains the SEO functions):
/public_html/templates/your_template/includes/head.tpl
You'll find this line of code which handles the SEO data:
{if $seo}{$seo}{else}<title>{$companyname} - {$pagetitle}{if $kbarticle.title} - {$kbarticle.title}{/if}</title>{/if}
{$seo} is a function pulled from Wizard Panel that handles the default pages editable in Wizard Panel. The else contents are WHMCS default applied to any pages that haven't been targeted. To add to this function first replace this line with:
{if $seo}
{$seo}
{elseif $filename eq "custom"}
<title>Page title goes here</title>
<meta name="description" content="Meta description goes here" />
<meta name="keywords" content="Meta, tags, go, here" />
{else}
<title>{$companyname} - {$pagetitle}{if $kbarticle.title} - {$kbarticle.title}{/if}</title>
{/if}
Change the value to target your page. You can also duplicate the {elseif}, title, description and tags code to target more pages.
Save the file and re-load the page and you should now see the SEO functions applied when viewing the page source.
Request Support
We hope you found this documentation useful. If you run into any issues we will be happy to assist you.