späť na hlavný modul | Dokumentácia | Built-in functions | | Odhlásiť sa

Built-in funkcie sú krátke zápisy, ktoré parser CMS systému rozpozná, spracuje a prepíše na konkrétnu hodnotu alebo hodnoty. Tieto zápisy sú vhodné na dynamicky generovaný obsah, napríklad na widgety (špeciálne objekty), aktuálny dátum, čas alebo vek. (Príklad: Namiesto vety Osoba na tomto obrázku má 20 rokov; je možné napísať: Osoba na tomto obrázku má { age|1/1/1995} rokov. Takúto vetu nie je treba viac aktualizovať, bude pravdivá aj o rok, pretože sa vždy zobrazí aktuálna hodnota. Pozn. príklad s vekom obsahuje medzeru za prvou zátvorkou, aby sa v príklade nezobrazila hodnota, ale zápis funkcie. )

widget Get special content type (menu,chart,google map...)
Syntax - Plugin content_type_id not loaded! }
{ widget|1|1} no pictures in this album
img Print image to the output. If file does not exist, default image is displayed. { img|src}
{ img|assets/img/fav_frontend.gif}
age Get age by date or time provided. { age|1987-11-11}
{ age|12/25/1988 15:30:00}
{ age|519654267}
config Get value of config variable. { config|fb_id}
{ config|langs}
{ config|page_title}
{ config|custom_attr}
Built-in functions
custom attribute value
session Get value of session according to its key. { session|name}
cookie Get value of cookie according to its key. { cookie|csrf_cookie_name}
{ cookie|_ga}
{ cookie|ci_sessions}
math Safely evaluating mathematical expressions { math|1+2+3+4+5}
{ math|(5+5)*6}
{ math|((1+1)*(2+2)*(3+3))/6 }
{ 125
{ math|pi}
email Preparing string construct for javascript to generate email address to protect it against spam bots. { email|admin|admin@kysuckylieskovec.sk} admin
sum Return the sum of the provided values { sum|1,2,3,4,5} 15
base_url Get base url { base_url}
{ base_url|parameter}
current_url Get current url { current_url} http://kysuckylieskovec.sk/built-in-functions
lang_url Get base url with language suffix { lang_url} http://kysuckylieskovec.sk/
lang Get language value by the provided key { lang|yes} Áno
    { getenv|REMOTE_ADDR} {getenv|REMOTE_ADDR}
constant Return the value of the constant indicated by name. Constant() is useful if you need to retrieve the value of a constant, but do not know its name. I.e. it is stored in a variable or returned by a function { constant|LANG} sk
    { gethostbyaddr|} {gethostbyaddr|}
    { gethostbyname|hostname} {gethostbyname|hostname}
    { gethostbynamel|kysuckylieskovec.sk} {gethostbynamel|kysuckylieskovec.sk}
    { gethostname} {gethostname}
    { getlastmod} {getlastmod}
date Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given. In other words, timestamp is optional and defaults to the value of time(). { date|Y-m-d}
{ date|Y-m-d|579846513}
{ date|Y-m-d||2678400}
{ date|Y-m-d||2678400|dec}
{ date|H:i:s||3600}
{ date|H:i:s||3600|dec}
time Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). { time} 1547605549
    { mktime} {mktime}
    { microtime} {microtime}
    { localtime} {localtime}
    { gettimeofday} {gettimeofday}
    { getdate} {getdate}
    { easter_date} {easter_date}
    { easter_days} {easter_days}
    { date_sunrise|789456123} {date_sunrise|789456123}
    { date_sunset|789456123} {date_sunset|789456123}
    { sin|90} {sin|90}
    { cos|90} {cos|90}
    { min|5|2|3|4} {min|5|2|3|4}
    { max|5|2|3|4} {max|5|2|3|4}
    { number_format|189|5} {number_format|189|5}
    { long2ip|92345678} {long2ip|92345678}
    { ip2long|} {ip2long|}
    { print_r|string|true} {print_r|string|true}

Returns a string containing a binary representation of the given number argument.

{ decbin|128} 10000000
    { dechex|128} {dechex|128}
    { decoct|128} {decoct|128}
    { bindec|1111} {bindec|1111}
    { bin2hex|1111} {bin2hex|1111}
abs Returns the absolute value of number. { abs|-156} 156
pow Returns base raised to the power of exp. { pow|5,3} 125
    { round|5.23} {round|5.23}
    { ceil|15.42} {ceil|15.42}
    { chr|122} {chr|122}
    { ord|z} {ord|z}
    { log|2000} {log|2000}
    { log10|100} {log10|100}
rand If called without the optional min, max arguments rand() returns a pseudo-random integer between 0 and getrandmax(). If you want a random number between 5 and 15 (inclusive), for example, use rand(5, 15). { rand|100|200} 192

Many random number generators of older libcs have dubious or unknown characteristics and are slow. By default, PHP uses the libc random number generator with the rand() function. The mt_rand() function is a drop-in replacement for this. It uses a random number generator with known characteristics using the Mersenne Twister, which will produce random numbers four times faster than what the average libc rand() provides. If called without the optional min, max arguments mt_rand() returns a pseudo-random value between 0 and mt_getrandmax(). If you want a random number between 5 and 15 (inclusive), for example, use mt_rand(5, 15).

{ mt_rand|10|100} 96
sha1 Calculates the sha1 hash of str using the US Secure Hash Algorithm 1 { sha1|string} ecb252044b5ea0f679ee78ec1a12904739e2904d
md5 Calculates the MD5 hash of str using the RSA Data Security, Inc. MD5 Message-Digest Algorithm, and returns that hash. { md5|string} b45cffe084dd3d20d928bee85e7b0f21

crypt() will return a hashed string using the standard Unix DES-based algorithm or alternative algorithms that may be available on the system. The salt parameter is optional. However, crypt() creates a weak password without the salt. PHP 5.6 or later raise an E_NOTICE error without it. Make sure to specify a strong enough salt for better security. password_hash() uses a strong hash, generates a strong salt, and applies proper rounds automatically. password_hash() is a simple crypt() wrapper and compatible with existing password hashes. Use of password_hash() is encouraged.

{ crypt|string|salt} $1$6A9bywVN$6KGgB2fjMlU4q3k3gCN6h1
    { crc32|string} {crc32|string}
    { convert_uuencode|I love PHP} {convert_uuencode|I love PHP}
    { convert_uudecode|*22!L;W9E(%!(4``` `} {convert_uudecode|*22!L;W9E(%!(4``` `}
    { metaphone|string} {metaphone|string}
phpversion Returns a string containing the version of the currently running PHP parser or extension. { phpversion}
    { scandir|assets} {scandir|assets}
    { realpath|assets} {realpath|assets}
    { dirname|assets} {dirname|assets}
    { uniqid|php_} {uniqid|php_}
    { get_current_user} {get_current_user}
    { getcwd} {getcwd}
    { getallheaders} {getallheaders}
    { php_uname} {php_uname}
    { php_ini_loaded_file} {php_ini_loaded_file}
    { php_ini_scanned_files} {php_ini_scanned_files}
    { php_logo_guid} {php_logo_guid}
    { php_sapi_name} {php_sapi_name}
    { memory_get_usage} {memory_get_usage}
    { memory_get_peak_usage} {memory_get_peak_usage}
    { posix_uname} {posix_uname}
    { apache_get_version} {apache_get_version}
    { token_name|260} {token_name|260}
pi Returns an approximation of pi. The returned float has a precision based on the precision directive in php.ini, which defaults to 14. Also, you can use the M_PI constant which yields identical results to pi(). { pi} 3.14159265359
    { rad2deg|15.5} {rad2deg|15.5}
    { soundex|string} {soundex|string}
    { levenshtein|abc|cda} {levenshtein|abc|cda}
    { iconv|UTF-8|ISO-8859-1//TRANSLIT|Euro €} {iconv|UTF-8|ISO-8859-1//TRANSLIT|Euro €}
    { htmlentities|I'll \"walk\" the dog now} {htmlentities|I'll \"walk\" the dog now}
    {{html_entity_decode|I'll "walk" the dog now} {html_entity_decode|I'll "walk" the dog now}
htmlspecialchars Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with these conversions made. If you require all input substrings that have associated named entities to be translated, use htmlentities() instead. { htmlspecialchars|Test|ENT_QUOTES} <a href="test">Test</a>
    { sprintf|string %s string|is} {sprintf|string %s string|is}
    { sqrt|25} {sqrt|25}
    { strlen|string} {strlen|string}
    { strrev|string} {strrev|string}
    { str_replace|s|a|ssstring} {str_replace|s|a|ssstring}
    { ucwords|this is a string, very short one.} {ucwords|this is a string, very short one.}
    { ucfirst|string} {ucfirst|string}
    { str_word_count|Counting string words} {str_word_count|Counting string words}
    { substr_replace|Replacing string|x|-5|2} {substr_replace|Replacing string|x|-5|2}
    { substr_count|This is a test|is} {substr_count|This is a test|is}
    { str_rot13|PHP 4.3.0} {str_rot13|PHP 4.3.0}
    { str_repeat|repeat-|10} {str_repeat|repeat-|5}
    { str_shuffle|string} {str_shuffle|string}
    { substr_compare|abcde|bc|1|2} {substr_compare|abcde|bc|1|2}
    { substr|string|2|2} {substr|string|2|2}
    { str_pad|string|10|xy|2} {str_pad|string|10|xy|2}
    { strtoupper|string} {strtoupper|string}
    { strtolower|STRING} {strtolower|STRING}
    { lcfirst|STRING} {lcfirst|STRING}
    { strstr|mail@mail.com|@} {strstr|mail@mail.com|@}
    { strtotime|2015/11/11} {strtotime|2015/11/11}
    { strftime|%A} {strftime|%A}
    { strpos|string|n} {strpos|string|n}
    { strrchr|this is a string|a} {strrchr|this is a string|a}
    { strcasecmp|Hello|hello} {strcasecmp|Hello|hello}
    { strcmp|Hello|Hello} {strcmp|Hello|Hello}
    { similar_text|first text|second text} {similar_text|first text|second text}
    { strip_tags|strong} {strip_tags|strong}
    { stripslashes|Strip a \' slash} {stripslashes|Strip a \' slash }
    { addslashes|Add a ' slash} {addslashes|Add a ' slash }
    { quotemeta|Hello world. (is it?)} {quotemeta|Hello world. (is it?)}
ternary Ternary operator logic is the process of using "(condition) ? (true return value) : (false return value)" statements to shorten your if/else structures. { ternary|1|equal|1|yes|no}
{ ternary|1|identical|1|yes|no}
{ ternary|1|not_equal|1|yes|no}
{ ternary|1|not_identical|1|yes|no}
{ ternary|1|greater|1|yes|no}
{ ternary|1|less|1|yes|no}
{ ternary|1|greater_equal|1|yes|no}
{ ternary|1|less_equal|1|yes|no}
ip_address Function to get the client IP address { ip_address},
Tieto stránky spravuje obec Kysucký Lieskovec