XOOPS API 2.5.11 Beta1  UI v0.5
Réalisé par monxoops.fr
Référence du fichier modifier.truncateHtml.php

Espaces de nommage

 Smarty
 

Fonctions

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

Documentation des fonctions

◆ 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:'...'}>

Paramètres
string$stringHTML to be truncated
integer$counttruncate to $count words
string$etcellipsis
Renvoie
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().

Paramètres
string$stringthe string being measured for length
Renvoie
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().

Paramètres
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.
Renvoie
string the extracted part of string, or FALSE on failure or an empty string.
Voir également
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 "..".

Paramètres
string$pathA path string.
string$suffixIf the name component ends in suffix this will also be cut off.
Renvoie
string the trailing name component of the given path.
Voir également
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.

Paramètres
string$pathA path string.
Renvoie
string the parent directory's path.
Voir également
http://www.php.net/manual/en/function.basename.php

Truncates a string to the number of characters specified.

Paramètres
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.
Renvoie
string the truncated string.

Truncates a string to the number of words specified.

Paramètres
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.
Renvoie
string the truncated string.

Truncate a string while preserving the HTML.

Paramètres
string$stringThe string to truncate
int$count
string$suffixString to append to the end of the truncated string.
string | bool$encoding
Renvoie
string
Depuis
2.0.1

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

Paramètres
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.
Renvoie
bool Returns true if first input starts with second input, false otherwise

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

Paramètres
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.
Renvoie
bool Returns true if first input ends with second input, false otherwise

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

Paramètres
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.
Renvoie
array
Depuis
2.0.4

Counts words in a string.

Depuis
2.0.8
Paramètres
string$string
Renvoie
int

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

Paramètres
int | float | string$value
Renvoie
string
Depuis
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.

Voir également
https://tools.ietf.org/html/rfc4648#page-7
Paramètres
string$inputthe string to encode.
Renvoie
string encoded string.
Depuis
2.0.12

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

Voir également
https://tools.ietf.org/html/rfc4648#page-7
Paramètres
string$inputencoded string.
Renvoie
string decoded string.
Depuis
2.0.12

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

The decimal separator will always be ..

Paramètres
float | int$numbera floating point number or integer.
Renvoie
string the string representation of the number.
Depuis
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.

Paramètres
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.
Renvoie
bool whether the string matches pattern or not.
Depuis
2.0.14