Jump to content

Has anyone posted links to knowledgebase articles outside of the root of whmcs


webberoo

Recommended Posts

Drop this into a php file in your WHMCS directory:

<?php
require("dbconnect.php");
require("includes/functions.php");
$result = mysql_query("SELECT id,title,article,votes FROM tblknowledgebase WHERE private!='on' ORDER BY votes DESC LIMIT 0,5");
while ($data = mysql_fetch_array($result)) {
 $id = $data["id"];
 $title = $data["title"];
 $article = $data["article"];
 $link = 'knowledgebase.php?action=displayarticle&id='.$id;
 echo('<b><a href="'.$link.'">'.strip_tags($title).'</a></b><br>'.truncate(strip_tags($article), 120).'<br><br>');
}

function truncate($string, $length = 80)
{
 if ($length == 0)
   return '';
 if (strlen($string) > $length) {
   $length -= strlen($etc);
   $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
   return substr($string, 0, $length).'...';
 } else {
   return $string;
 }
}
?>

You will need to adjust the $link variable... And if you are going to reuse the output on other websites, I'd opt to output as as RSS feed and then use a reader script on the other websites to handle the display... But this should get you going...

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