└── char_limit ├── icon.png ├── addon.setup.php ├── README.md └── pi.char_limit.php /char_limit/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EllisLab/Char-Limit/HEAD/char_limit/icon.png -------------------------------------------------------------------------------- /char_limit/addon.setup.php: -------------------------------------------------------------------------------- 1 | 'Packet Tide', 5 | 'author_url' => 'http://packettide.com/', 6 | 'name' => 'Character Limiter', 7 | 'description' => 'Permits you to limit the number of characters in some text', 8 | 'version' => '2.0.1', 9 | 'namespace' => 'User\Addons\CharLimit', 10 | 'settings_exist' => FALSE 11 | ); 12 | -------------------------------------------------------------------------------- /char_limit/README.md: -------------------------------------------------------------------------------- 1 | # Char-Limit 2 | 3 | Wrap anything you want to be processed between the tag pairs. 4 | 5 | {exp:char_limit total="100" exact="no"} 6 | text you want processed 7 | {/exp:char_limit} 8 | 9 | The "total" parameter lets you specify the number of characters. 10 | The "exact" parameter will truncate the string exact to the "limit" 11 | The "strip_tags" parameter will remove any HTML tags from the input string 12 | The "force_ellipses" parameter will add ellipses to the output when exact is used and the result is trimmed 13 | 14 | Note: When exact="no" this tag will always leave entire words intact so you may get a few additional characters than what you specify. 15 | 16 | ## Change Log 17 | 18 | - 2.0.1 19 | - Added add-on icon 20 | - Updated License information 21 | - 2.0 22 | - Updated plugin to be 3.0 compatible 23 | - 1.3 24 | - Add "force_ellipses" parameter 25 | - 1.2 26 | - Add "exact" parameter 27 | - 1.1 28 | - Updated plugin to be 2.0 compatible 29 | 30 | ## License 31 | 32 | Copyright (C) 2004 - 2016 EllisLab, Inc. 33 | 34 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 35 | 36 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 37 | 38 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ELLISLAB, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 39 | 40 | Except as contained in this notice, the name of EllisLab, Inc. shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from EllisLab, Inc. 41 | -------------------------------------------------------------------------------- /char_limit/pi.char_limit.php: -------------------------------------------------------------------------------- 1 | TMPL->fetch_param('total')) ? 500 : ee()->TMPL->fetch_param('total'); 51 | $total = ( ! is_numeric($total)) ? 500 : $total; 52 | 53 | //exact truncation 54 | $exact = ee()->TMPL->fetch_param('exact', 'no'); 55 | $strip_tags = ee()->TMPL->fetch_param('strip_tags', 'no'); 56 | $force_ellipses = ee()->TMPL->fetch_param('force_ellipses', 'no'); 57 | 58 | $str = ($str == '') ? ee()->TMPL->tagdata : $str; 59 | 60 | if ($strip_tags == 'yes') 61 | { 62 | $str = strip_tags($str); 63 | } 64 | 65 | if (in_array($exact, array('yes', 'y'))) 66 | { 67 | if ((strlen($str) > $total) AND in_array($force_ellipses, array('yes', 'y'))) 68 | { 69 | $str = trim(substr($str, 0, $total)).'…'; 70 | } 71 | else 72 | { 73 | $str = substr($str, 0, $total); 74 | } 75 | } 76 | else 77 | { 78 | $str = ee()->functions->char_limiter($str, $total); 79 | } 80 | 81 | $this->return_data = $str; 82 | } 83 | } 84 | // END CLASS 85 | 86 | /* End of file pi.char_limit.php */ 87 | /* Location: ./system/user/addons/char_limit/pi.char_limit.php */ 88 | --------------------------------------------------------------------------------