WHMCS Mod: Top Knowledgebase Articles On Any Page

Wed, Jul 1, 2009

General

WHMCS

WHMCS

While browsing the WHMCS Forums, I found this post. It seemed like quite a simple tasks, and the overall issue was the same problem I had bumped into when I was writing another mod for the system. The issue with WHMCS is that some variables are only available on specific pages; since all of the WHMCS files are encoded, you can only modify the pages using the integrated tempate system which uses the Smarty Template Engine.

So anyway, the task was to show the top few knowledgebase articles on any template page in WHMCS. Rather than explaining how to install it here, I have just written a little readme.txt file and put that in with the other files. Installation should take you no more than 5 minutes. You can download it here (zip).

Please don’t host this anywhere else. If you would like to link to it, please just link to this post.

Update: Following a readers request, here is a modified version which allows you to get you knowledge base articles on any page (even if it’s not in the WHMCS directory). You can download this versionΒ here.

I am releasing this mod under the Creative Commons: Share Alike 2.0 License!

Creative Commons License
WHMCS KB Mod by Ben Harris is licensed under a Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License.

Update: Thanks to the 160 users to date who found my mod useful :p http://www.whmcs.com/members/communityaddons.php?action=viewmod&id=32

, ,

16 Comments For This Post

  1. Abe Says:

    Great mod πŸ™‚

    Not exactly what I was looking for, but close enough.
    I think I can edit this to have them show on my home page, thanks!

  2. Ben Says:

    Hi Abe, Thanks for the comment. I have actually built a version of it to work on any page (I guess my note at the bottom isn’t very clear). You can download it here http://ben90.com/share/projects/WHMCS/Top-Knowledgebase-Articles-On-Any-Page/version/1.0/top-kb-articles-on-any-non-whmcs-page.zip

  3. Abe Says:

    Aaarrr…. No, I didn’t see that!

    I think my brain saw the creative commons licence and switched off.
    Maybe putting the “Update:” in bold will make it stand out a little more, as this page seems to have better SERPs.

    Well, thanks for the code… It’s going to a good home πŸ™‚

  4. Ben Says:

    Hi Abe, I have moved and bolded the “Update:” now so its a bit clearer. Just also thought that I would add that it’s really nice to hear that my code is being used πŸ™‚ and thanks for the comments πŸ™‚

  5. AJIT Says:

    Hi

    But does this work with Kayako integrated KB in the WHMCS system also?

    AJIT

  6. Ben Says:

    Hi AJIT, I doubt that it will work with a Kayako integrated KB. The mod takes the KB articles directly from the WHMCS DB. It probably wouldn’t be too hard to get it working with Kayako though. Unfortunately I don’t have the Kayako Support Suite to play with, so I cannot really develop it.

  7. Tracy Says:

    I have tried to no avail, but don’t know how to make it show only the articles in the associated category. Say, my category is ‘FTP’, how would I get only those related articles to show, and not The Top Knowledgebase Articles’???

    I don’t know anything about SQL Queries, but I have tried to write it to SELECT the column_name (say parentid or whatever) from the tblknowledgebase table_name, but it doesn’t work.

    When you click on the actual category name, (FTP) from the KB list of categories page, you’re taken to a page where you can see all the related articles. I just want it so the user can view a list of them in the sidebar area, vs. clicking back and forth.

    Any ideas how to do this??

    Thanks,
    Tracy

  8. Ben Says:

    Hi Tracy,

    I have not tested this however it should work.

    Replace:

    $result = mysql_query( "SELECT * FROM tblknowledgebase ORDER BY views DESC LIMIT " . $numArticles );

    With:

    $result = mysql_query( "SELECT * FROM tblknowledgebase, tblknowledgebaselinks WHERE tblknowledgebase.id = tblknowledgebaselinks.articleid AND categoryid = 'CATEGORYID' ORDER BY views DESC LIMIT " . $numArticles );

    You would of course need to replace CATEGORYID with the id of the category that you would like to get the top articles from.

    Regards

    Ben

  9. Tracy Says:

    That didn’t really work. It shows a specific list of articles from one category in any category. So if I’m in the FTP category, with how I have the CATEGORYID set, it shows the FTP articles. And when I switch to the email category, it still only shows the list of FTP articles. I’d like the articles to display under the correct category, when you click on that category; perhaps there’s no way.

    Also, I don’t enough about databases and columns and tables, but here’s what I did, and don’t really understand why it doesn’t work.

    In phpMyAdmin, I created a new text column in tblknowledgebase and in tblknowledgebasecats and named them both ‘sort’.

    In tblknowledgebase, in the field for column sort, I labeled the FTP Articles ‘one’ and the Email Articles ‘two’.

    In tblknowledgebasecats, in the field for column sort, I labeled the FTP category ‘one’. And labeled the Email category ‘two’.

    These are ‘unique’ columns in both tables. I first created the columns as numeric, but numbers 1 and 2 did not make them unique because of their keys; for whatever reason they are unique as text, but it still does not sort them using the code below. Instead every article shows up in every category. Instead of only FTP articles in FTP category and Email Articles in the Email category. You would think it would work (logically, the code looks and reads right), but it doesn’t??

    $result = mysql_query( “SELECT * FROM tblknowledgebase, tblknowledgebasecats WHERE tblknowledgebase.sort = tblknowledgebasecats.sort ORDER BY views DESC LIMIT ” . $numArticles );

    I thought by omitting the use of tblknowledgebaselinks and using tblknowledgebasecats instead, I would have more control over which articles and category to choose and match them.

    I’m thinking I should just use a different helpdesk altogether vs. the built in one offered by WHMCS, because I cannot seem to create an article menu for the individual category pages, and have them display correctly.

    Thanks!
    Tracy

  10. Ben Says:

    Hi Tracy,

    I think that I may have a solution, I’m away from home at the moment, but I will see what I can do when I return home in a few days time.

    Ben

  11. Ben Says:

    Hi Tracy,

    The following query should do it for you πŸ™‚

    $result = mysql_query( "SELECT * FROM tblknowledgebase, tblknowledgebaselinks WHERE tblknowledgebase.id = tblknowledgebaselinks.articleid AND categoryid = '" . $_GET['catid'] . "' ORDER BY views DESC LIMIT " . $numArticles );

    Ben

  12. Tracy Says:

    Hi, thanks! That does work, but not completely. The right articles do show up, but not on the actual article page. When I click on the Category, for instance, from the knowledge base list, all of the articles show up on the following page, but then disappear when I click on an article topic and am taken to the page to read the article. That’s really where I would like them to be displayed, so the user does not have to click back and forth; if that makes sense.

    Thank you!
    Tracy

  13. Ben Says:

    Right, Try this πŸ™‚

    $result = mysql_query( "SELECT * FROM tblknowledgebase,tblknowledgebaselinks WHERE tblknowledgebase.id = tblknowledgebaselinks.articleid AND categoryid = (SELECT categoryid FROM tblknowledgebaselinks WHERE articleid = '" . $_GET['id'] . "') ORDER BY views DESC LIMIT " . $numArticles );

    It should work, but I have not extensively tested it.

    Ben

  14. Tracy Says:

    No need in testing it Ben, I did it for you, and it WORKS! You are a genius! Do you realize there is nothing else on the internet to be found that can do what you just did; as well as your original solution to having the articles on any page. Incredible! You should be proud, I know I am very, very appreciative!!! πŸ™‚ Thank You!

    Now my next dilemma… and there always seems to be a next.. LOL! I have created PDF files for each article and would like the correct linked file to show up on the correct article page; along with the links that say ‘Add to Favorites’ and ‘Print this Article’. I have something working, but it’s more manual, it would be nice if there were a more automated solution. I’m not asking for your help, you’ve done enough, and again, I am so grateful!!! πŸ™‚

    Thanks again! It works beautifully!
    Tracy

  15. Mambo Web Hosting Says:

    Its a great piece of work. However, it appears like the developer has stopped maintaining it and there are not new versions for the current WHMCS version ie 5.2.5.
    I think the idea was great and i would have encouraged the developer to charge some little fee to support development.
    Thank You,
    Mambo Web Hosting – Kenya Largest Hosting Company

  16. Ben Says:

    Sorry, I’m afraid this was one of those projects that I just forgot about (and I’ve been terrible at checking this blog). If you ever need some custom work done, I am available for hire πŸ™‚ – me [at] ben90 [dot] com

Leave a Reply