From cbe3247819be75c34231ea200874044735bd853b Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Thu, 5 Aug 2010 14:09:20 -0500 Subject: Adding an ellipsize function to the text helper, and associated documentation to the user guide. --- user_guide/changelog.html | 1 + user_guide/helpers/text_helper.html | 12 ++++++++++++ 2 files changed, 13 insertions(+) (limited to 'user_guide') diff --git a/user_guide/changelog.html b/user_guide/changelog.html index ce017c9fd..f32ee58b3 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -128,6 +128,7 @@ Hg Tag:

  • The img() function of the HTML helper will now generate an empty string as an alt attribute if one is not provided.
  • If CSRF is enabled in the application config file, form_open() will automatically insert it as a hidden field.
  • Added sanitize_filename() into the Security helper.
  • +
  • Added ellipsize() to the Text Helper
  • Other Changes diff --git a/user_guide/helpers/text_helper.html b/user_guide/helpers/text_helper.html index d477f53a9..438eaec45 100644 --- a/user_guide/helpers/text_helper.html +++ b/user_guide/helpers/text_helper.html @@ -177,7 +177,19 @@ of text that will help
    us demonstrate this
    function +

    ellipsize()

    +

    This function will strip tags from a string, split it at a defined maximum length, and insert an ellipsis.

    +

    The first parameter is the string to ellipsize, the second is the number of characters in the final string. The third parameter is where in the string the ellipsis should appear from 0 - 1, left to right. For example. a value of 1 will place the ellipsis at the right of the string, .5 in the middle, and 0 at the left.

    +

    An optional forth parameter is the kind of ellipsis. By default, … will be inserted.

    + +$str = 'this_string_is_entirely_too_long_and_might_break_my_design.jpg';
    +
    +echo ellipsize($str, 32, .5);
    + +Produces: + +this_string_is_e…ak_my_design.jpg -- cgit v1.2.3-24-g4f1b