Jump to content

How do I add the knowledgebase category to browser title?


Convergence

Recommended Posts

I just figured out how to do this. It's pretty easy to do.

 

Open your header.tpl and at the top before

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

add

{php}
$result = full_query("SELECT name FROM tblknowledgebasecats WHERE id = '" . sanitize($_GET['catid']) . "' LIMIT 1;"); 
$data   = mysql_fetch_array($result);

$this->assign('categoryname', $data['name']);
{/php}

Now edit your <title> to be

<title>{$companyname} - {$pagetitle} {if $categoryname} - {$categoryname}{/if}{if $kbarticle.title} - {$kbarticle.title}{/if}</title>

 

This took me about 10 minutes to figure out from a previous posting that m00 gave.

Link to comment
Share on other sites

Thanks!

 

Getting closer, but not quite there...

 

<title>{$companyname} - {$pagetitle} {if $categoryname} - {$categoryname}{/if}{if $kbarticle.title} - {$kbarticle.title}{/if}</title>

 

Does put the Category in the title:

 

<title>DomainName.ext - Knowledgebase - Billing</title>

 

When someone clicks on:

 

DomainName.ext/whmcs/knowledgebase/2/Billing

 

However,

 

When someone clicks on an article, the title reads:

 

<title>DomainName.ext - Knowledgebase - Will my credit card statement show DomainName.ext?</title>

 

I'd like it to show:

 

<title>DomainName.ext - Knowledgebase - Billing - Will my credit card statement show DomainName.ext?</title>

 

Where the Category Name is inserted between "Knowledgebase" and "Article".

 

Any suggestions and thanks again!

 

PS: Thanks sparky, but your suggestion did not work for me.

Edited by Convergence
Link to comment
Share on other sites

Hi there. Try this code in top of you header.tpl file:

{php}
if($_GET['action'] == "displaycat" OR $_GET['action'] == "displayarticle")
{
if(is_numeric($_GET['catid']))
	$catid 		= $_GET['catid'];
elseif(is_numeric($_GET['id']))
	$catid 		= $this->_tpl_vars['kbarticle']['categoryid'];

$result = full_query("SELECT name FROM tblknowledgebasecats WHERE id = '" . sanitize($catid) . "' LIMIT 1;"); 
$data   = mysql_fetch_array($result);

$this->assign('categoryname', $data['name']);
}
{/php}

Link to comment
Share on other sites

here is a start for you... change your title tag in your header.tpl to this

 

damn and i was so close :(

 

Yes, you were, bravo! For the life of me I couldn't figure out how to get the database involved to pull the category.

 

Thanks again to everyone for their great efforts!

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