Atomic Posted December 25, 2016 Share Posted December 25, 2016 We are going to be rapidly expanding our Knowledgebase with up to 500 articles and would like to make the layout a little more appealing. Is there a way to add custom icons? For example instead of a folder icons we'd like a WordPress icon. An email icon for Email articles etc. Merry Christmas! 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted December 25, 2016 Share Posted December 25, 2016 it's doable with some editing in TPL files and maybe ActionHook file 0 Quote Link to comment Share on other sites More sharing options...
Atomic Posted December 25, 2016 Author Share Posted December 25, 2016 Uh....ok..... 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted December 25, 2016 Share Posted December 25, 2016 quick example: create new PHP file in /includes/hooks/ directory, and add the following code in it: <?php add_hook("ClientAreaPage", 1, function($vars){ $defaultIcon = "glyphicon glyphicon-folder-close"; $kbIcons = array( 1 => "glyphicon glyphicon-dashboard", 4 => "glyphicon glyphicon-envelope", 5 => "glyphicon glyphicon-download-alt" ); foreach ($vars['kbcats'] as $index => $kb){ if (isset($kbIcons[$kb['id']])){ $vars['kbcats'][$index]['icon'] = $kbIcons[$kb['id']]; } else { $vars['kbcats'][$index]['icon'] = $defaultIcon; } } return array("kbcats" => $vars['kbcats']); }); you will see that at line #4 we define the default icon, this icon will be used with categories with no specific icon defined then there is a list/array of category ids and their icons (Category ID => "Icon Class Name") now we need to apply this changes to our template, open /templates/{Your-Template}/knowledgebase.tpl file, search for: <span class="glyphicon glyphicon-folder-close"></span> {$kbcat.name} and replace it with: <span class="{$kbcat.icon}"></span> {$kbcat.name} you may need to apply the same change in knowledgebasecat.tpl too 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted December 25, 2016 Share Posted December 25, 2016 here is how it looks like 0 Quote Link to comment Share on other sites More sharing options...
Atomic Posted December 25, 2016 Author Share Posted December 25, 2016 Thanks. Sorry to be a dunce but I don't seem to have a "glyphicon" folder? 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted December 25, 2016 Share Posted December 25, 2016 glyphicon is font, included by default in Bootstrap: http://getbootstrap.com/components/#glyphicons you can use FontAwesome as well: http://fontawesome.io/icons/ it will be "fa fa-dashboard" instead of "glyphicon glyphicon-dashboard" 0 Quote Link to comment Share on other sites More sharing options...
Atomic Posted December 25, 2016 Author Share Posted December 25, 2016 Got it. But if I wanted to use something custom would I put the image path in the array? I highly doubt things like cPanel and Wordpress exist in Glyphicos or FontAwesome? 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted December 25, 2016 Share Posted December 25, 2016 Got it. But if I wanted to use something custom would I put the image path in the array? I highly doubt things like cPanel and Wordpress exist in Glyphicos or FontAwesome? then you would need to change how this implementation work: <?php add_hook("ClientAreaPage", 1, function($vars){ $defaultIcon = "<span class="glyphicon glyphicon-folder-close"></span>"; $kbIcons = array( 1 => "<img src='path/to/image.png' alt=''>", 4 => "<span class="glyphicon glyphicon-envelope"></span>", 5 => "<span class="glyphicon glyphicon-download-alt"></span>" ); foreach ($vars['kbcats'] as $index => $kb){ if (isset($kbIcons[$kb['id']])){ $vars['kbcats'][$index]['icon'] = $kbIcons[$kb['id']]; } else { $vars['kbcats'][$index]['icon'] = $defaultIcon; } } return array("kbcats" => $vars['kbcats']); }); and in template files it will be: {$kbcat.icon} {$kbcat.name} 0 Quote Link to comment Share on other sites More sharing options...
Atomic Posted December 25, 2016 Author Share Posted December 25, 2016 Thank you sir. Going to attempt this tomorrow. Really appreciate the time especially on Christmas Day! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 4, 2017 Share Posted January 4, 2017 I think I answered a similar question a few months earlier... https://forum.whmcs.com/showthread.php?118842-Image-for-each-category-in-Knowledgebase 0 Quote Link to comment Share on other sites More sharing options...
Atomic Posted January 5, 2017 Author Share Posted January 5, 2017 Thank you both. I've had to put this on the backburner as we are in the middle of migrating our cloud. There goes my sleep for the next 8 weeks. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.