API - XOOPS 2.5.11 Beta 2
By monxoops.fr
modifier.truncateHtml.php File Reference

Namespaces

namespace  Smarty
 

Functions

 smarty_modifier_truncateHtml ($string, $count=80, $etc='…')
 

Function Documentation

◆ smarty_modifier_truncateHtml()

smarty_modifier_truncateHtml (   $string,
  $count = 80,
  $etc = '…' 
)

Smarty truncateHtml modifier plugin

Type: modifier Name: truncateHtml Purpose: Truncate an HTML string to a certain number of words, while ensuring that valid markup is maintained. Example: <{$body|truncateHtml:30:'...'}>

Parameters
string$stringHTML to be truncated
integer$counttruncate to $count words
string$etcellipsis
Returns
string

The Yii framework is free software. It is released under the terms of the following BSD License.

Copyright © 2008-2018 by Yii Software LLC, All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Yii Software LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Returns the number of bytes in the given string. This method ensures the string is treated as a byte array by using mb_strlen().

Parameters
string$stringthe string being measured for length
Returns
int the number of bytes in the given string.

Returns the portion of string specified by the start and length parameters. This method ensures the string is treated as a byte array by using mb_substr().

Parameters
string$stringthe input string. Must be one character or longer.
int$startthe starting position
int$lengththe desired portion length. If not specified or null, there will be no limit on length i.e. the output will be until the end of the string.
Returns
string the extracted part of string, or FALSE on failure or an empty string.
See also
http://www.php.net/manual/en/function.substr.php

Returns the trailing name component of a path. This method is similar to the php function basename() except that it will treat both \ and / as directory separators, independent of the operating system. This method was mainly created to work on php namespaces. When working with real file paths, php's basename() should work fine for you. Note: this method is not aware of the actual filesystem, or path components such as "..".

Parameters
string$pathA path string.
string$suffixIf the name component ends in suffix this will also be cut off.
Returns
string the trailing name component of the given path.
See also
http://www.php.net/manual/en/function.basename.php

Returns parent directory's path. This method is similar to dirname() except that it will treat both \ and / as directory separators, independent of the operating system.

Parameters
string$pathA path string.
Returns
string the parent directory's path.
See also
http://www.php.net/manual/en/function.basename.php

Truncates a string to the number of characters specified.

Parameters
string$stringThe string to truncate.
int$lengthHow many characters from original string to include into truncated string.
string$suffixString to append to the end of truncated string.
string$encodingThe charset to use, defaults to charset currently used by application.
bool$asHtmlWhether to treat the string being truncated as HTML and preserve proper HTML tags. This parameter is available since version 2.0.1.
Returns
string the truncated string.

Truncates a string to the number of words specified.

Parameters
string$stringThe string to truncate.
int$countHow many words from original string to include into truncated string.
string$suffixString to append to the end of truncated string.
bool$asHtmlWhether to treat the string being truncated as HTML and preserve proper HTML tags. This parameter is available since version 2.0.1.
Returns
string the truncated string.

Truncate a string while preserving the HTML.

Parameters
string$stringThe string to truncate
int$count
string$suffixString to append to the end of the truncated string.
string | bool$encoding
Returns
string
Since
2.0.1

Check if given string starts with specified substring. Binary and multibyte safe.

Parameters
string$stringInput string
string$withPart to search inside the $string
bool$caseSensitiveCase sensitive search. Default is true. When case sensitive is enabled, $with must exactly match the starting of the string in order to get a true value.
Returns
bool Returns true if first input starts with second input, false otherwise

Check if given string ends with specified substring. Binary and multibyte safe.

Parameters
string$stringInput string to check
string$withPart to search inside of the $string.
bool$caseSensitiveCase sensitive search. Default is true. When case sensitive is enabled, $with must exactly match the ending of the string in order to get a true value.
Returns
bool Returns true if first input ends with second input, false otherwise

Explodes string into array, optionally trims values and skips empty ones.

Parameters
string$stringString to be exploded.
string$delimiterDelimiter. Default is ','.
mixed$trimWhether to trim each element. Can be:
  • boolean - to trim normally;
  • string - custom characters to trim. Will be passed as a second argument to trim() function.
  • callable - will be called for each value instead of trim. Takes the only argument - value.
bool$skipEmptyWhether to skip empty strings between delimiters. Default is false.
Returns
array
Since
2.0.4

Counts words in a string.

Since
2.0.8
Parameters
string$string
Returns
int

Returns string representation of number value with replaced commas to dots, if decimal point of current locale is comma.

Parameters
int | float | string$value
Returns
string
Since
2.0.11

Encodes string into "Base 64 Encoding with URL and Filename Safe Alphabet" (RFC 4648).

‍Note: Base 64 padding = may be at the end of the returned string. = is not transparent to URL encoding.

See also
https://tools.ietf.org/html/rfc4648#page-7
Parameters
string$inputthe string to encode.
Returns
string encoded string.
Since
2.0.12

Decodes "Base 64 Encoding with URL and Filename Safe Alphabet" (RFC 4648).

See also
https://tools.ietf.org/html/rfc4648#page-7
Parameters
string$inputencoded string.
Returns
string decoded string.
Since
2.0.12

Safely casts a float to string independent of the current locale.

The decimal separator will always be ..

Parameters
float | int$numbera floating point number or integer.
Returns
string the string representation of the number.
Since
2.0.13

Checks if the passed string would match the given shell wildcard pattern. This function emulates [[fnmatch()]], which may be unavailable at certain environment, using PCRE.

Parameters
string$patternthe shell wildcard pattern.
string$stringthe tested string.
array$optionsoptions for matching. Valid options are:
  • caseSensitive: bool, whether pattern should be case sensitive. Defaults to true.
  • escape: bool, whether backslash escaping is enabled. Defaults to true.
  • filePath: bool, whether slashes in string only matches slashes in the given pattern. Defaults to false.
Returns
bool whether the string matches pattern or not.
Since
2.0.14