Jump to content

Keep knowlegbase titles looking good...


robb3369

Recommended Posts

After trying to keep three columns of knowledgebase categories looking good and somewhat aligned with their rather short titles and descriptions, I came across a nice smarty plugin to do just that. Its based on the wordpress plugin called widont. It basically prevents a sentence from wrapping and only having one word on the second line, so rather than you having to rewrite the sentence to look better, this modifier takes care of it.

 

Save this in your WHMCS/includes/smarty/plugins as modifier.widont.php:

<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*
* Type:     modifier<br>
* Name:     widont<br>
* Purpose:  add an   between the last two words of a paragraph to prevent orphan words (widows)
*           based on Shaun Inman's Widon't wordpress plugin
* @author   J Cornelius <smarty at jcornelius dot com>
* @param   string  $string  the string to manipulate
* @return  string           the string with an   added
*/
function smarty_modifier_widont($string = '')
{
  return preg_replace('|([^\s])\s+([^\s]+)\s*$|', '$1 $2', $string);
}
?>

And you can you it (for example) in the knowledgebase.tpl and knowledgebasecat.tpl files. Just change the occurrence of

{$kbcat.description}

to

{$kbcat.description|widont}

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