Dynamic Knowledgebase - HOW TO (Simple mod!)

Everything related to Hesk - helpdesk software

Moderator: mkoch227

Post Reply
TechCoder
Posts: 12
Joined: Fri Sep 15, 2017 3:44 pm

Dynamic Knowledgebase - HOW TO (Simple mod!)

Post by TechCoder »

If you are like me, you have a LOT of docs and articles that could go into the knowledgebase, but you hesitate to put them up for your users to see because, just about the time you put them up, someone from 'Admin' wants to change some number somewhere - and that puts a ton of work back on you to update the articles!

But, no more! :)

Using HESK (and Mods For Hesk), we have a WONDERFUL way to now keep the docs UP TO DATE on all the changes made - and the 'Admin' folks can make changes that won't burn up your time!

Dynamic Knowledgebase

Following are the SIMPLE instructions to make your knowledgebase articles DYNAMIC! (the code is kept simple-for-anyone to implement and follow along, though could be trimmed by more advanced programmers)
  • add a file (let's call it 'dynamic_knowledgebase.php') to the /inc directory (you can name/put it anywhere, as long as you know how to point to it below)
    • add the following array to the file

      Code: Select all

      $knowledgebase[dynamic'] = array(
           "%%FIRSTITEM%%" => "Dynamic data for Item #1",  // just an example, you can use ANY sort of variable you like!
           "%%SECONDITEM%%" => "Dynamic data for Item #2"
      );
      (this is the file where you will store all your 'dynamic' bits of data PRO POINT: make references back to your main config file and/or database to make sure there is ONE location for this data being stored!)
  • open /inc/common.inc.php in your code editor
    • add this function to the BOTTOM of the page (makes it simple to find)

      Code: Select all

      function dynamic_knowledgebase($content) {
          include_once HESK_PATH . "inc/dynamic_knowledgebase.php";  // Note that this IS correct!
          foreach($knowledgebase['dynamic'] as $key => $value){
              $content = str_replace($key,$value,$content);
          }
          return $content;
      }
  • in the ROOT of your HESK installation, look for the file "knowledgebase.php" and open it in your code editor.
    • search for "$article =" (you should find 3 instances - note that not all 3 are the same - but that is OK!)
      • BELOW THE LINE with '$article =' in it (i.e., you are inserting NEW code AFTER that line, not modifying anything already there), add the following code

      Code: Select all

      if (!empty($article['content'])) {
          $article['content'] = dynamic_knowledgebase($article['content']);
      }
      (remember to do this for all 3 locations in this file)
  • in the /admin folder of your HESK installation, look for the file "knowledgebase_private.php" and do the SAME as above (again, 3 places).
OK, that is IT for the coding!

Now, go create a new KB article with the following text:
Isn't it FANTASTIC how we can now, using a SIMPLE mod, have %%FIRSTITEM%%, %%SECONDITEM%% and MORE - in fact, as many DYNAMIC items as you could ever want!
Save the article and go take a look at it!
Isn't it FANTASTIC how we can now, using a SIMPLE mod, have Dynamic data for Item #1, Dynamic data for Item #2 and MORE - in fact, as many DYNAMIC items as you could ever want!
ENJOY!
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: Dynamic Knowledgebase - HOW TO (Simple mod!)

Post by Klemen »

Thanks for sharing your mod, indeed useful if you want to display data that changes a lot.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply