Skip to main content

Smarty Plugin

You can use Smarty plugins for custom processing or batch processing.
This documents provides the list of available Smarty plugins in Kuroco.

Kuroco's Smarty engine is a customized fork of Smarty 2 with several language-level extensions on top of the standard syntax. The behaviors documented in Kuroco-specific Smarty extensions below apply to every template running in Kuroco — not just to the individual plugins listed in the rest of this page.

Smarty syntax note: embedded variables with backticks

When the value of a Smarty tag attribute is a double-quoted string and the variable inside contains characters that Smarty does not treat as part of an identifier — such as ., [, ], or -> — you must wrap the variable in backticks (`). Otherwise Smarty fails to parse the dotted / bracketed / arrow expression inside the string.

{* OK: a simple $-variable inside a double-quoted attribute *}
{assign var="aa" value="$arg"}

{* OK: backticks let Smarty parse the full expression inside the string *}
{assign var="aa" value="`$arg.name`"}
{assign var="aa" value="`$item[0].title`"}
{assign var="aa" value="`$obj->prop`"}

{* OK: no quotes at all — passes the expression as a raw value *}
{assign var="aa" value=$arg.name}

{* NG: dotted variable inside a double-quoted string without backticks
— Smarty raises a syntax error and the template fails to compile *}
{assign var="aa" value="$arg.name"}

This is the standard Smarty "embedded variables" syntax (see the Smarty manual). It is easy to overlook and often misread by tooling/AI, so prefer the backtick form whenever the variable expression includes ., [], or -> inside a double-quoted attribute value.

Kuroco-specific Smarty extensions

Safe array access for undefined keys

Inside templates, array element access is handled safely so that referencing a key that does not exist returns null instead of raising a PHP warning. This applies uniformly to bracket notation and dot notation.

{* Both forms return null (not a warning) if the key is missing *}
{$arr[key]}
{$config.site.title}

Practical implications:

  • You can safely reference keys that may not exist — the result is null.
  • This safety net is not applied when the variable is the first operand of a reference-taking modifier (|@sort, |@rsort, |@asort, |@arsort, |@ksort, |@krsort, |@array_push, |@array_pop, |@array_shift, |@shuffle). For those, make sure the variable is actually defined before applying the modifier.

|smarty:nodefaults and |raw — bypass default modifiers

If a global default modifier chain is configured, prefix a variable's modifier chain with |smarty:nodefaults (or its alias |raw) to suppress it for that specific output.

{$html_content|raw}              {* skip default escape/etc. *}
{$untrusted|smarty:nodefaults} {* same effect *}

$smarty.* differences in Kuroco

ReferenceBehavior in Kuroco
$smarty.cookiesDisabled. Always evaluates to null. Read cookies on the server side instead.
$smarty.envDisabled. Always evaluates to null.
$smarty.serverAllowed, but sensitive keys (DOCUMENT_ROOT, SCRIPT_FILENAME, SERVER_SOFTWARE, SERVER_ADDR, SERVER_PORT, REMOTE_PORT, REDIRECT_STATUS, etc.) are stripped before reaching the template. Other $_SERVER keys are exposed normally.
$smarty.rcms_validateKuroco-only. Truthy while the template is being executed in validation mode. Use it to skip side-effectful work during dry-run validation.
{if !$smarty.rcms_validate}
{* skipped during validation runs *}
{api endpoint="..." method="POST" var=resp}
{/if}

{php} block is unavailable

Standard Smarty 2's {php}...{/php} block and inline PHP tags (<?php ?>) cannot be used in Kuroco templates — Kuroco runs Smarty in security mode and does not permit raw PHP from a template. Use plugin tags ({assign}, {assign_array}, {append}, {api}, etc.) and the allow-listed function calls described below instead.

Allowed PHP functions in {if} conditions

{if} and {elseif} expressions can only call PHP functions that appear in Kuroco's IF_FUNCS allow-list. Any other function call inside a condition is rejected at compile time.

{if isset($user) && is_array($user) && count($user) > 0}
...
{/if}
CategoryAllowed names
Functionsis_null, count, is_array, in_array, isset, is_object
Pseudo-constants accepted as bare wordsnull / NULL, true / TRUE, false / FALSE

For anything else, compute the boolean in advance with {assign} or a modifier, then test the result in {if}.

Modifiers — plugins vs. PHP-function pass-through

Modifiers in Kuroco templates come from two distinct sources, and it matters which one you're using:

  1. Modifier plugins — files such as modifier.count.php, modifier.empty.php, modifier.in_array.php, modifier.split.php, modifier.to_object.php. Each plugin defines a modifier of the same name, and works regardless of the PHP-function allow-list below. Examples: {$arr|@count}, {$user|empty}, {$item|to_object}. The full set of available modifier plugins is part of the plugin catalog later on this page.
  2. PHP-function pass-through — any function in Kuroco's MODIFIER_FUNCS allow-list can be used as a modifier even though no plugin file exists for it. The call goes through a type-validation wrapper, so if an argument's type does not match the function's signature the result is null (and the error is surfaced through Kuroco's error pipeline outside of validation mode) — there is no PHP fatal error.
{$text|strlen}              {* PHP-function pass-through *}
{$arr|@count} {* served by modifier.count.php plugin *}
{$value|intval} {* PHP-function pass-through *}

Behavioral notes:

  • The @ prefix retains its standard Smarty meaning: apply the modifier to the array as a whole rather than mapping it over each element. It is not a Kuroco-specific marker.
  • Reference-taking functions (sort, push, etc.) interact with the safe array access behavior — see the exception list above.

MODIFIER_FUNCS allow-list (PHP-function pass-through)

These PHP functions can be invoked as modifiers without a dedicated plugin file. The list is grouped roughly by purpose. Functions implemented as modifier plugins (such as count, empty, in_array) are not on this list — they're served by their plugin files and are listed in the per-plugin section below.

GroupFunctions
String / textstrlen, substr, strstr, strpos, stripos, strtolower, strtoupper, str_pad, trim, nl2br, strip_tags, htmlspecialchars_decode, html_entity_decode, escape, escapeCSV, urlencode, rawurldecode, md5, password_hash, password_verify
Multibyte textmb_strlen, mb_substr, mb_strpos, mb_stripos, mb_strwidth, mb_strimwidth, mb_convert_kana, mb_convert_encoding
Array — readis_array, array_key_exists, array_keys, array_values, array_column, array_search, array_slice, array_filter, array_unique, array_diff, range, key, property_exists
Array — write / sortarray_push, array_pop, array_shift, array_merge, array_reverse, sort, rsort, ksort, krsort, asort, arsort, shuffle, implode, explode, join, unset
Number / castmin, max, floor, round, intval, floatval, strval, is_numeric, mt_rand, number_format
Date / timestrtotime, rcms_strtotime
URL / encodingparse_url, http_build_query, base64_encode, base64_decode, json_encode, filter_var, pathinfo
Misc / Kuroco helpershtml_convert, check_inner_uri, getCountryFromIP, defined

Extended assign() signature (server-side / plugins)

When assigning template variables from PHP, Kuroco's assign() accepts two extra parameters used in custom plugins and assign_array-style tags:

$smarty->assign(string|array $var, mixed $value = null, string $type = 'auto', bool $nullable = false);
ParamValuesEffect
typeauto (default), str / string, int / integer, bool / boolean, float, arrayCasts $value to the requested type before assignment.
nullablefalse (default) / trueWhen true, falsy-but-not-explicitly-zero values are stored as null instead of being coerced (e.g. an empty string becomes null for type=int, but a real 0 stays as 0).

Dot-notation in the variable name creates nested arrays automatically (supported up to 4 levels deep):

$smarty->assign('user.profile.age', 30);  // -> $user['profile']['age'] = 30
$smarty->assign('items.', $value); // -> $items[] = $value (empty trailing key = push)

Building arrays in templates — best practices

Smarty 2 has no built-in array literal syntax, so Kuroco templates rely on a small set of helpers. Pick the pattern that matches your shape:

1. Initialize, then push (most common)

The canonical pattern: declare an empty array with assign_array, then add elements one by one with append. This is what most existing Kuroco templates use.

{assign_array var=items values=""}
{append var=items value="first"}
{append var=items value="second"}
{append var=items value=$dynamic_value}

For associative arrays, pass index to {append}:

{assign_array var=person values=""}
{append var=person index="name" value="Katoh"}
{append var=person index="age" value=28}

2. One-shot literal from a delimited string

When the values are static, build the array in a single tag:

{* List *}
{assign_array var=colors values="red,green,blue"}

{* Custom delimiter (when values contain commas) *}
{assign_array var=paths values="/a;/b;/c" delimiter=";"}

{* Associative (keys and values must have the same count) *}
{assign_array var=opts keys="host,port,ssl" values="example.com,443,true"}

3. Dot notation for nested structures

Both the standard {assign} tag and the extended PHP-side assign() accept dot-paths in the variable name to create nested arrays in one step (up to 4 levels deep):

{assign var="user.profile.name" value="Katoh"}
{assign var="user.profile.age" value=28}
{assign var="user.roles." value="admin"} {* trailing dot pushes to $user.roles *}
{assign var="user.roles." value="editor"}

Result:

user => Array
profile => Array (name=Katoh, age=28)
roles => Array ("admin", "editor")

4. Immutable variant — keep the original array unchanged

{append} mutates var in place. When you need to derive a new array without touching the source, use assign_array_set:

{assign_array_set var=updated from=$original key="status" value="done"}
{* $original is unchanged; $updated has the extra key *}

Picking between the patterns

ShapeRecommended pattern
Indexed list, items known statically{assign_array values="a,b,c"}
Indexed list, items added in a loop{assign_array values=""} + {append}
Flat associative map, ≤ 1 level{assign_array keys=... values=...} or {append index=...}
Nested structure (object-like){assign var="a.b.c" value=...} dot notation
Need to preserve the original{assign_array_set}

Array-specific pitfalls

  • Do not rely on accidental indexing into a string or scalar. Because of the safe array access behavior, {$x[0]} against a non-array silently returns null — easy to misread as a real value. Initialize arrays explicitly with {assign_array} before indexing into them.
  • Always initialize an array before {append}-ing to it. Start every list with {assign_array var=foo values=""} so the receiving variable is guaranteed to be an array. Calling {append} on a variable that hasn't been initialized (or that was set to a scalar) does not produce the expected array, especially across {include} boundaries.

add

Add a number to a variable.

Attributes

ParamTypeDescription
varStringThe variable name to which the addition is performed. The result of the addition is also stored in the same variable name. (required)
valueIntNumber

Example

{add var=i value=5}

api

Call an external API.

Sends a request to an external service that provides an API and stores the response in a variable.

Attributes

ItemUsageExampleNote
endpointEndpoint (required)https://example.com/brah/
methodMethodPOST/GET/PATCH/PURGE/PUT/DELETE/HEAD
queryQuery stringparam1=hoge&param2=foo
queriesQuery array$params
json_bodyRequest JSON body{param1:"hoge",param2:"foo"}
bodyRequest body
filesFile['path/to/hoge.jpg', 'path/to/foo.png']/
[{'path':'path/to/hoge.jpg'}, {'path':'path/to/foo.png'}]
Specify the relative path from the Kuroco temporary folder.
headersRequest headers['Host: localhost','user-agent: hoge']Specify as an array.
cache_timeCache time (minutes)20
varStorage variable of the responseresponse
json_varStorage variable of the responseresponseIf the response is in JSON format, the decoded value is stored.
resp_header_varResponse header storage variableheaderThe response headers will be stored in an array format.
dl_flgDownload flagtrue/falseIf true, the response is saved as a file in the Kuroco temporary area.
status_var0: Failure 1: SuccessstatusReturns whether the request was successful or not.
timeoutTimeout60Specify the timeout (in seconds).
sslcertsecret key of mTLS client certificateSSLCERT001Specify a Kuroco secret key of mTLS client certificate
sslkeysecret key of mTLS client secret keySSLKEY001Specify a Kuroco secret key of mTLS client secret key
cainfosecret key of mTLS Server CA infoCAINFO001Specify Kuroco secret key of mTLS Server CA info

Example

Sending a file with PUT

To send a file to a specific URL with the PUT method, specify an array of file paths in the files attribute. However, only one file can be sent at a time. Therefore, all elements after the second element in the specified array will be ignored.

{write_file var=tmp_path value="This is test."}
{assign_array var=files values=""}
{append var=files value=$tmp_path}
{api
endpoint='https://www.example.com/brah/'
method="PUT"
var=response
files=$files
status_var=status
}

Sending text with PUT

To send text with PUT, set the text you want to send to the json_body attribute or the body attribute. If it is in JSON format, set the value to the json_body attribute.

{assign_array var=product values=""}
{append var=product index=name value='apple'}
{append var=product index=price value='160'}
{assign var=json value=$product|@json_encode}
{api
endpoint='https://www.example.com/brah/'
method='PUT'
json_body=$json
var=response
status_var=status
}

If the text is not in JSON format, set the value to the body attribute.
In this case, you must specify something in the Content-Type of the request header in the format text/***. Also, note that even if the text is not in JSON format, you still need to add the json_encode modifier, similar to the settings when using json_body (this is because the multi-byte character part needs to be escaped to Unicode).

{assign_array var=headers values=""}
{append var=headers value='Content-Type: text/csv'}
{assign var=csv value="ID,NAME,PRICE\n1,apple,150\n2,orange,200"}
{api
endpoint='https://www.example.com/brah/'
method='PUT'
headers=$headers
body=$csv|@json_encode
var=response
status_var=status
}

Communicate by performing server-to-server authentication using mTLS authentication
If mTLS authentication is required to link with an external system, you can communicate with Kuroco as an mTLS client. First, save the contents of the server CA certificate, client certificate, and client private key as secrets. You must specify the secret key name when saving. Please specify this secret key name as follows.

{api 
endpoint='https://xxx.xxx.xxx/xxxx/'
method='GET'
var='response'
status_var='status'
sslcert='SSLCERT001'
sslkey='SSLKEY001'
cainfo='CAINFO001'
}

The client CA certificate used when creating the client certificate and client private key must be registered as a connection source certificate that is allowed on the mTLS server side. The registration method differs depending on the system, so please contact the provider of each service. Please receive the server CA certificate set here from the destination server. The connection results are output to the API log, so please refer to it when making settings.

Sending a Deploy Hook to Vercel
You can use it as a webhook to trigger a build on an external hosting service.

{api
endpoint='https://api.vercel.com/v1/integrations/deploy/prj_******************'
method="POST"
var=response
status_var=status
}

Related Document
For information on how to call Kuroco's internal API using custom function, refer to Can I call Kuroco's API using custom function?.

api_internal

Requests an API internally and assign the response.

Attributes

ParamTypeDescription
endpointStringEndpoint (required)
methodStringMethod (POST/GET)
queryStringQuery string
queriesArrayQuery array
headersArrayRequest headers
cache_timeIntegerCache time (minutes)
varStringVariable name to store the response
status_varString0:Failed 1:Success
member_idIntegerExecute as the specified login member
*Note: Cannot be used in conjunction with the 'direct' parameter.
use_current_sessionBooleanExecute API request by taking over the current session
directBooleanExecute API request directly without going through the network (curl)
*Note: You can specify direct=true as a parameter only if the HTTP method of the target endpoint is GET. It cannot be used in conjunction with 'member_id'.

Example

{api_internal
endpoint='/rcms_api/1/sample'
method='GET'
query='ex=1&ex2=2'
cache_time=20
var='response'
status_var='status'}

api_method

Operations on each model are performed without creating an endpoint. Only operations with the GET method are available. Operations with the POST method cannot be used.

Attributes

ParamTypeDescription
varStringThe variable name to store the result (required)
modelStringModel
methodStringMethod (operation)
versionIntegerVersion
request_paramsArrayRequest variables
method_paramsArrayMethod settings. Same as "Basic Settings" and "Advanced Settings" on the endpoint settings page.

Example

{* Endpoint configuration parameters *}
{assign_array var='method_params' values=''}
{assign_array var='method_params.topics_group_id' values='1'}
{* Query parameters *}
{assign_array var='request_params' values=''}
{assign var='request_params.cnt' value=20}
{assign var='request_params.pageID' value=1}
{api_method
var='topics_list'
model='Topics'
method='list'
version='1'
method_params=$method_params
request_params=$request_params}

test:{$topics_list|@debug_print_var}
{* For the details endpoint, specify the ID in method_params. *}
{assign_array var='method_params' values=''}
{assign var='method_params.ext_group' value=true}
{assign var='method_params.topics_id' value=1234}
{api_method
var='topics_details'
model='Topics'
method='details'
version='1'
method_params=$method_params}

test:{$topics_details|@debug_print_var}

api_mng

Requests a management API internally and assigns the response.

append

Append a new element to an array from a template.

Attributes

ParamTypeDescription
varStringThe name of the array (required)
valueStringThe name of the object or array to add (required)
indexIntegerThe index of the array where to start adding (optional)

Example

{append var=options value='Option N' index='N'}

array_key_exists

Checks if a key exists in an array. PHP5-compatible Smarty modifier.

Attributes

ParamTypeDescription
arrayArrayThe array to check in (Required)

Returns

Returns true if the key exists in the array, false otherwise. Also returns false if the second parameter is not an array.

Example

{if $key|array_key_exists:$array}Key exists{/if}

{* Check for numeric key *}
{if 0|array_key_exists:$array}First element exists{/if}

Notes:

  • Checks for the existence of a key, not the value, and returns true even when the value is null.
  • Returns false if the second parameter is not an array (safe handling).

assign_api_credential

Generate a new API request and get the access key in val.

Attributes

ParamTypeDescription
dg_keyStringThe key to generate DG_CODE
dg_idStringThe id to generate DG_CODE
api_keyStringThe key to generate sid request (required)
varArrayThe name of the returning array
jwt_dataArrayJWT data
member_idIntegerMember ID
expireIntegerExpiration time (in seconds)

Example

{assign_api_credential
api_key=$api_key
dg_key="topics_edit_api"
dg_id="0"
var=val}

assign_array

Assign an array as a template variable.

Attributes

ParamTypeDescription
varStringThe name of the variable to assign the array to (required)
valuesStringThe values to store in the array. A string separated by a delimiter
delimiterStringThe delimiter to use to split the values specified in 'values'. The default is a comma
keysStringIf it's an associative array, specify the keys. The default is null

Example

{assign_array var="foo" values="bar1,bar2"}
{assign_array var="foo" values="bar1;bar2;bar3" delimiter=";"}
{assign_array var="foo" keys="key1,key2,key3" values="bar1,bar2,bar3"}

assign_array_diff

Assigns the difference array between array1 and array2.

Attributes

ParamTypeDescription
varStringName of the assigned diff array
array1ArrayArray 1
array2ArrayArray 2
diff_modeStringMode of the diff array: normal, key

Example

{assign_array_diff
var="foo"
array1=$array1
array2=$array2
diff_mode='normal'}

assign_array_intersect

Assigns the intersection array between array1 and array2.

Attributes

ParamTypeDescription
varStringName of the assigned intersect array
array1StringArray 1
array2StringArray 2
intersect_modeStringMode of the intersect array: normal, assoc, key (default=normal)

Example

{assign_array_intersect
var="foo"
array1=$array1
array2=$array2
intersect_mode='normal'}

assign_array_set

Append an element to an array.
This function is similar to {append}, but this function appends element without changing the original array.

Attributes

ParamTypeDescription
varStringThe name of the return variable (required)
fromStringOriginal array
keyStringkey name
valueStringvalue

Example

{assign_array var="person" values=""}
{append var="person" index="name" value="Katoh"}
{append var="person" index="job" value="Sales"}
{assign_array_set var="person_ex" key="age" value="28" from=$person}

{$person_ex|@debug_print_var}

{$person|@debug_print_var}

Output

Array (4)
name => "Katoh"
job => "Sales"
age => "28"

Array (2)
name => "Katoh"
job => "Sales"

assign_csv_table

Retrieve a master indicated by csvtable_id.

Attributes

ParamTypeDescription
csvtable_idIntegerThe ID of the master (required)
varStringThe name of the return variable (required)
get_key_valBooleanEnable the use of optional parameters. (optional)
key_idxInteger/ArrayReturn dimension or dimensions to be returned. (optional)
value_idxIntegerReturn dimension or dimensions to be returned. (optional)
multipleBooleanDistinguish by the number of dimensions. (optional)
langStringIf it supports multiple languages, specify the language such as "ja", "en", etc.
filterStringSpecifies the filter condition.(optional)
allow_listStringSpecifies the key name to be filtered (required when using the filter).

Example

{assign_csv_table csvtable_id=X var="sample_table1"}
{$sample_table1|@debug_print_var}
{assign_csv_table
csvtable_id=X
var="sample_table2"
get_key_val=true}
{$sample_table2|@debug_print_var}
{assign_csv_table csvtable_id=X var="sample_table3" filter="key=\"test\"" allow_list="key"}
{$sample_table3|@debug_print_var}

assign_favorite_cnt

Retrieve favorite count.

Attributes

ParamTypeDescription
module_typeStringThe module name. Specify one of "topics","comment","member","tag","csvtable", or "ec_product". The default is "topics".
module_idIntegerThe ID of the specified module.
varStringThe name of the variable to store the result (required).
timeStringThe strtotime format.
formatStringThe format.

Example

{assign_favorite_cnt
module_type="topics"
module_id=1000
var="favorite_cnt"}

assign_globals

Assigns global variables that can be shared between custom processes called within the same request.

Attributes

ParamTypeDescription
varStringVariable name to store global variables.
keyStringKey for global variables.
valueMixedValue of the global variable.
unsetBoolTo clear the value of a variable, specify true.

Example

{assign_globals key='prev_content' value=$content}
{assign_globals var='prev_content' key='prev_content'}

assign_group_nm

Retrieve group names.

Attributes

ParamTypeDescription
group_idIntegerGroup ID (required)
varStringThe name of the variable to store the result (required).
langStringThe language code (e.g., "ja", "en").

Example

{assign_group_nm group_id=100 var='group_nm'}

assign_member_detail

Retrieve member's information.

Attributes

ParamTypeDescription
varStringThe name of the variable to store the result (Required)
member_idIntThe member ID of the value to retrieve (Required)|
open_by_groupBooleanWhen false, the viewing permission is ignored. The default value is true.
open_flgInt(Deprecated) When -1, only information about members who can view is retrievable.
assign_group_flgBooleanWhether to retrieve group information or not.

Example

{assign_member_detail var='varname' member_id=7}

assign_my_favorite_cnt

This function retrieves the number of contents that the user has marked as their favorite.

Attributes

ParamTypeDescription
module_typeStringThe name of the module. Specify one of "topics", "comment", "member", "tag", "csvtable", or "ec_product". The default is "topics".
module_idIntegerThe ID of the specified module.
varStringThe variable name to store the result (required).
cookie_flgIntegerThe flag for getting favorite contents with cookie management.
action_typeStringThe target action (default 0 (like)).

Example

{assign_my_favorite_cnt
module_type="topics"
var="favorite_cnt"
cookie_flg=1}

assign_new_comment_list

Retrieves the comments attached to the specified content, sorted from the newest to the oldest.

Attributes

ParamTypeDescription
module_idStringThe ID of the module where the content is specified.
module_typeStringThe name of the module. Specify either "topics", "comment", "member", "tag", "csvtable", or "ec_product". Default is "topics".
varBooleanThe variable name to store the result (required).
new_order_flgStringWhen set to false, the results are returned in ascending order.
cntStringLimits the number of results. Default is 5.

Example

{assign_new_comment_list
module_id=1
module_type='topics'
cnt=5
var='new_comment_list'
}

assign_relation_tag_list

Retrieve the list of tags associated with the specified content.

Attributes

ParamTypeDescription
moduleStringModule name
module_idIntegerID in the specified module (required)
varStringVariable name to store the result (required)
tag_category_idIntegerIf you want to narrow down by tag category, specify the tag category ID (optional)
tag_relation_listArrayArray of tags. It must be an array of arrays that have id (optional)

Example

{assign_relation_tag_list
module="topics"
module_id=123
var="rel_tag_list"}
{assign_array var=tag1 values=""}
{append var=tag1 index=id value=101}
{append var=tag1 index=tag_nm value="WeaklyRecommended"}

{assign_array var=tag2 values=""}
{append var=tag2 index=id value=102}
{append var=tag2 index=tag_nm value="Important"}

{assign_array var=tag_list values=""}
{append var=tag_list value=$tag1}
{append var=tag_list value=$tag2}

{assign_relation_tag_list
module="topics"
module_id=123
tag_relation_list=$tag_list
var="rel_tag_list"}

assign_tag_category_list

Returns a list of category tags.

Attributes

ParamTypeDescription
varStringThe name of the variable to store the result in (required)
langStringLanguage code setting
tree_flgBooleanFlag for outputting tag hierarchy structure (e.g. parent and child tags) (returns 1)

Example

{assign_tag_category_list [tree_flg=true] var=tag_category_list}

assign_tag_list

Gets the tags associated with the tag category.

Attributes

ParamTypeDescription
varStringThe name of the variable to store the result in (required)
category_idIntegerThe ID of the category tag to specify (required)
orderArrayAn array that specifies the output order of tags.

Example

{assign_tag_list category_id='02' var='tag_list'}
{assign_tag_list category_id='02' order='open_contents_cnt:desc' var='tag_list'}
{assign_tag_list category_id='02' order=$tag_order var='tag_list'}

assign_topics_category_list

Retrieve a list of contents associated with the specified category.

Attributes

ParamTypeDescription
varStringThe variable name to store the result (required).
topics_group_idIntegerThe topics_group_id of the category group to be specified (required).
langStringLanguage setting.

Example

{assign_topics_category_list
topics_group_id=1
var='topics_category_list'}

assign_topics_detail

Get detailed information of the specified content.

Attributes

ParamTypeDescription
varStringVariable name to store the result (required)
topics_idIntegerID of the content (required)
langStringLanguage setting
chk_open_flgBooleanWhether to limit the content to only those that are currently open. The default is true.

Example

{assign_topics_detail topics_id=100 var='topics_data'}

Attributes

ParamTypeDescription
endpointStringEndpoint (required)
methodStringHTTP Method (POST/GET)
queryStringQuery string
queriesArrayQuery array
headersArrayRequest headers
filesArrayUploaded files
varStringVariable to store the response
status_varString0: Failure 1: Success
member_idIntegerExecute as the specified login member
use_current_sessionBooleanExecute API request by inheriting the current session

Example

{api_mng
endpoint='/management/<module>/sample'
method='GET'
query='ex=1&ex2=2'
var='response'
status_var='status'}

backup

Performs a backup.

Attributes

ParamTypeDescription
typeStringSpecify "full"
memoStringMemo for the backup
result_varStringVariable name to store the result

Example

{backup type='full' memo='smarty' result_var='res'}

backup_delete

Deletes a backup.

You must specify either a backup ID or a backup period (start date and end date). If a backup ID is specified, the backup period (start date and end date) will be ignored.

Attributes

ParamTypeDescription
backup_idStringSpecify the backup ID
start_dateStringSpecify the start date of the backup period to delete
end_dateStringSpecify the end date of the backup period to delete
result_varStringVariable name to store the result. If the deletion is successful, it returns true; if it fails, it returns false.

Example

{backup_delete backup_id='1234' result_var='res'}
{backup_delete start_date='2020-01-01 00:00:00' end_date='2020-01-01 23:59:59' result_var='res'}

batch

Attributes

ParamTypeDescription
batch_idIntegerBatch ID (Either this value or name is required)
nameStringSlug of batch (Either this value or batch_id is required)
moduleStringTarget module name (It used when you register default batch)
ext_dataArrayData to pass to the registered batch.
varStringVariable name which stores registered batch id

Example

{batch batch_id='1234' ext_data=$ext_data}

break

Used inside loops such as foreach or section. When break is executed, the program immediately exits the loop.

Attributes

none

Example

{break}

capitalize

Capitalizes the first letter of each word.

Attributes

ParamTypeDescription
uc_digitsBooleanCapitalize words starting with digits (Optional, default false)

Returns

The capitalized string.

Example

{$title|capitalize}
{"hello world"|capitalize} {* Hello World *}
{"test 123abc hello"|capitalize} {* Test 123abc Hello *}
{"test 123abc hello"|capitalize:true} {* Test 123Abc Hello *}
{"it's a test"|capitalize} {* It's A Test *}

Notes:

  • Respects apostrophes at word start — words beginning with ' are not capitalized.
  • By default, words starting with digits are left unchanged; set uc_digits=true to capitalize them as well.
  • Uses word boundaries (\b) so punctuation is handled correctly, and words containing apostrophes (such as "it's") are kept together.

cat

Concatenates a value to a variable.

Attributes

ParamTypeDescription
catMixedValue to append (Optional, default "")

Returns

The concatenated string.

Example

{$name|cat:" Smith"}
{"Hello"|cat:" World"}
{$path|cat:".txt"}
{$count|cat:" items"}

Notes:

  • Both operands are checked with is_scalar(); non-scalar values (arrays, objects, null) contribute an empty string instead of causing errors.
  • Booleans are converted per PHP standard: true"1", false"".

child_site

Get data of a child site.

Attributes

ParamTypeDescription
site_keyStringSite key (required)
varStringName of the variable to store the result (required)

Example

{child_site var='site' site_key='1234'}

continue

This is used within loops such as foreach and section. When continue is executed, the remaining processing of the loop is skipped and the program moves on to the next loop processing.

Attributes

None

Example

{continue}

conv_bool

Converts a value to a boolean using Kuroco's internal convBool() function. Useful for normalizing assorted truthy/falsy values (such as form inputs or API string fields) to strict booleans.

Example

{$value|conv_bool}

{* Use in conditionals *}
{if $string_value|conv_bool}
Value is truthy
{/if}

Get/set Cookie.

Attributes

ParamTypeDescription
varStringVariable name
keyStringKey
valueStringString value
expiresIntegerExpiration date of the cookie in days
overwriteIntegerOverwrite flag

Example

{cookie key="foo" value="test"}

count

Counts the number of elements in an array. PHP7-compatible Smarty count modifier.

Returns

An integer representing the number of elements in the array. Returns 0 if the input is not an array.

Example

{$array|count}

Notes:

  • Works with both indexed and associative arrays; returns 0 for empty arrays.
  • Unlike PHP's native count(), this modifier returns 0 for non-array values instead of 1.

count_characters

Counts the number of characters in text.

Attributes

ParamTypeDescription
include_spacesBooleanInclude whitespace in count (Optional, default false)

Returns

An integer count.

Example

{"Hello World"|count_characters}       {* 10 *}
{"Hello World"|count_characters:true} {* 11 *}
{"Tab\there"|count_characters} {* 7 - excludes tab *}

Notes:

  • With include_spaces=false (default), whitespace characters (space, tab, newline, carriage return, form feed, vertical tab) are excluded.
  • NOT multibyte-safe — counts bytes, not characters. Use only with ASCII or single-byte encodings.

count_paragraphs

Counts the number of paragraphs in text.

Returns

An integer count.

Example

{$article|count_paragraphs}
{"First paragraph\n\nSecond paragraph"|count_paragraphs} {* 2 *}
{"Line1\nLine2\nLine3"|count_paragraphs} {* 3 *}
{"Single line"|count_paragraphs} {* 1 *}

Notes:

  • Splits the text on one or more newline characters (\r, \n, or \r\n) and counts the resulting array elements.
  • Multiple consecutive newlines are treated as a single separator; an empty string returns 1.

count_sentences

Counts the number of sentences in text.

Returns

An integer count.

Example

{$text|count_sentences}
{"Hello. How are you? I'm fine."|count_sentences} {* 3 *}
{"Mr. Smith went home."|count_sentences} {* 1 - "Mr." not counted *}
{"End of line."|count_sentences} {* 1 *}

Notes:

  • Counts periods that are preceded by a non-whitespace character and not followed by a word character, so abbreviations like "Dr." or "Mr." are skipped when followed by more text.
  • Only periods are counted — question marks and exclamation points are not.

count_words

Counts the number of words in text.

Returns

An integer count.

Example

{$text|count_words}
{"Hello world 123"|count_words} {* 3 *}
{" spaces only "|count_words} {* 2 *}
{"!!!"|count_words} {* 0 - no alphanumerics *}

Notes:

  • Splits the text on whitespace, then counts only the resulting elements that contain at least one alphanumeric character (ASCII letters, digits, or extended/multibyte characters 0x800xff).
  • Pure punctuation sequences are not counted as words.

date

Assigns a date variable.

Attributes

ParamTypeDescription
varStringVariable name to store the result (required)
timeStringstrtotime format
formatStringFormat

Example

{date var='yesterday' time='Yesterday' format='Y-m-d'}
{date var='today' format='Y-m-d H:i:s'}

date_format

Formats a datestamp using PHP date() format characters.

Attributes

ParamTypeDescription
formatStringDate format string (Optional, default 'Y-m-d')
default_dateStringDefault date if input is empty (Optional, default '')

Returns

The formatted date string, or nothing if both the input and default_date are empty.

Example

{$timestamp|date_format}
{$date|date_format:"%Y-%m-%d"}
{$datetime|date_format:"Y-m-d H:i:s"}
{"2024-01-15"|date_format:"F j, Y"}
{$maybe_empty|date_format:"Y-m-d":"2024-01-01"}

Notes:

  • Uses smarty_make_timestamp() to parse the input, so it supports Unix timestamps, date strings, and MySQL-style values.
  • If the format string contains %, strftime-style codes are converted to PHP date() equivalents (%YY, %mm, %dd, %HH, %Mi, %Ss, etc.) before formatting.

debug_print_var

Formats a variable's contents for display in the debug console.

Attributes

ParamTypeDescription
depthIntegerCurrent recursion depth (used internally; Optional, default 0)
lengthIntegerMaximum string length before truncation (Optional, default 300)

Returns

An HTML-formatted representation of the variable.

Example

{$var|debug_print_var}
{$array|debug_print_var:0:100}

Notes:

  • Arrays show as Array (count), objects as ClassName Object (count), booleans as <i>true</i>/<i>false</i>, and null as <i>null</i>.
  • Special characters are rendered as HTML italics (<i>\n</i>, <i>\r</i>, <i>\t</i>), strings are truncated via rcms_mbtruncate() with a ... suffix, and output is HTML-escaped for safe display.

default

Provides a default value for empty variables.

Attributes

ParamTypeDescription
defaultMixedDefault value if empty (Optional, default '')

Returns

The original value, or the default if the input is unset or an empty string.

Example

{$name|default:"Anonymous"}
{$count|default:0}
{$message|default:"No message"}

Notes:

  • Only an unset value or an empty string '' (strict comparison) is treated as empty.
  • Falsy values such as 0 and false are NOT considered empty — this differs from PHP's empty().

detect_document_text

Detects (OCR) text from PDF/TIFF files using Google Cloud Vision API.

info

This plugin can only be executed in batch processing or in test mode on the admin panel.

Attributes

ParamTypeDescription
varStringVariable name to store the result (required)
dirStringFile directory (e.g. /files/topics) (required)
file_nmStringFile name (required when module_id is not specified)
module_idIntegerModule ID (required when file_nm is not specified)
ext_idIntegerExtension item ID
noIntegerFile number (default: 0 for /files/topics, otherwise null)
langStringLanguage code
slugStringSlug
typeStringOutput format: "text" (default) or "array"
no_cacheBooleanDisable cache (default: false)

There are two ways to specify the target file:

  1. By file name: Specify dir and file_nm.
  2. By module parameters: Specify dir and module_id, along with optional parameters such as ext_id, no, lang, and slug.

Output format

  • When type="text" (default): The detected text from all pages is concatenated with double newlines (\n\n) and returned as a single string.
  • When type="array": The result is returned as an array of objects, each containing page (page number) and value (detected text for that page).

If an error occurs (e.g., unsupported file format, file not found), an empty array [] is assigned to the variable.

Supported file formats

  • PDF (.pdf)
  • TIFF (.tiff)
caution

S3-hosted files are not supported.

Supported file directories

The following file directories are supported by this plugin:

  • /files/topics (GCS/KurocoFiles)
  • /files/inquiry (GCS/KurocoFiles)
  • /files/member/ext (GCS/KurocoFiles)
  • /files/d (KurocoFiles)

Caching

The extracted text is cached in the database. On subsequent calls with the same file, the cached result is returned if the file has not been updated. Use no_cache=true to bypass the cache.

Example

{* Specify by file name *}
{detect_document_text var="text" dir="/files/d" file_nm="document.pdf"}

{* Specify by module ID *}
{detect_document_text var="text" dir="/files/topics" module_id=123 ext_id=1}

{* Get result as array *}
{detect_document_text var="pages" dir="/files/d" file_nm="document.pdf" type="array"}

{* Disable cache *}
{detect_document_text var="text" dir="/files/topics" module_id=123 ext_id=1 no_cache=true}

empty

Checks whether a value is empty, with enhanced handling for stdClass objects.

Returns

true if the value is empty, false otherwise.

Example

{if $value|empty}Value is empty{/if}

{* Works with objects too *}
{if $object|empty}Object has no properties{/if}

Notes:

  • Empty values include empty string "", 0, null, false, and the empty array [].
  • Also returns true for an empty stdClass object (no properties) — useful when API responses occasionally return empty objects rather than empty arrays. This differs from PHP's native empty().

escape

Escapes a string according to the specified type.

Attributes

ParamTypeDescription
esc_typeStringEscape type: html, htmlall, url, urlpathinfo, quotes, hex, hexentity, decentity, javascript, mail, nonstd (Optional, default 'html')
char_setStringCharacter set (Optional, default 'UTF-8')

Returns

The escaped string.

Example

{$html|escape}
{$html|escape:"html"}
{$url|escape:"url"}
{$js_string|escape:"javascript"}
{$email|escape:"mail"}

Notes:

  • Escape types include: html (htmlspecialchars with ENT_QUOTES), htmlall (htmlentities with ENT_QUOTES), url (rawurlencode), urlpathinfo (same as url but preserves /), quotes (escape unescaped single quotes), hex/hexentity/decentity (per-character encoding), javascript (escape backslash, quotes, newlines, and </<\/), mail (replace @ and . with [AT] and [DOT]), and nonstd (escape characters with ordinal ≥ 126).
  • null or non-scalar input returns an empty string; unknown escape types return the input unchanged.

explode

Splits a string into an array using a delimiter. PHP8-compatible with safe type handling.

Attributes

ParamTypeDescription
stringString/NumberThe string to split (Required)

Returns

An array of strings split by the delimiter. Returns an empty array [] if the string is empty or not a string/numeric type.

Example

{* Basic split *}
{','|explode:$csv_string}

{* Split path *}
{'/'|explode:$file_path}

{* Works with numeric input *}
{'-'|explode:12345}

Notes:

  • The delimiter is the modifier input; the string to split is passed after the colon.
  • Numeric input (int/float/double) is converted to a string before splitting.
  • Only literal delimiters are supported (no regex). For regex support, use the split modifier.

function

Calls a custom function.

Attributes

ParamTypeDescription
varStringVariable name to store the result (required)
idIntegerID of the custom function
nameStringIdentifier of the custom function

Example

If you have defined a custom function "sub_function" as follows and called it using the function plugin, the variable $result will be assigned with the value "Hello World".

{* Caller *}
{function name="sub_function" var="result" param1="Hello" param2="World"}
{* Custom function definition. Identifier: sub_function *}
{assign var="message" value=$param1|cat:" "|cat:$param2}
{return value=$message}

gcloud_functions_token

Obtain a bearer token for authentication with Google Cloud Functions.

Attributes

ParamTypeDescription
varStringVariable name to store the result (required)
urlStringURL of the function (required)
sa_secret_nameStringName of the secret for the service account set in the secret_edit screen.

Example

{gcloud_functions_token
var="id_token"
url="https://us-central1-**.cloudfunctions.net/functionName"
sa_secret_name='GCP_MY_CREDENTIAL'}

gcloud_pubsub_publish

Delivers a message to Google Cloud Pub/Sub.

Attributes

ParamTypeDescription
varStringVariable name to store the result (required)
topicStringTopic name to deliver the message to (required)
messageAnyMessage to be delivered (required)
projectStringGCP project name
sa_secret_nameStringSecret name of the service account set in the secret_edit page

Example

{gcloud_pubsub_publish
var='result'
project='projectName'
topic='topicName'
message=$message
sa_secret_name='MY_GCP_CREDENTIAL'}

generate_pdf

Generate a PDF or image based on the specified URL. The generated file will be saved on GCS.

Note that generate_pdf uses the headless browser Puppeteer. The width and height of the headless browser can be controlled by various options.

Prerequisites
To use generate_pdf, you need to integrate it with Firebase. Refer to Cloud storage integration with Firebase for integration.

Attributes

ItemDescriptionExample
urlSpecify the URL of the page to convert to PDF.https://www.diverta.co.jp
pathSpecify the file storage location for the generated PDF. It will be located under files/g/private/ or files/g/public/.files/g/private/sample.pdf
optionSpecify the options for PDF conversion.
browser_widthSpecify the browser width.browser_width=1280
browser_heightSpecify the browser height.browser_height=2560
sleepSpecify the waiting time (in milliseconds) until the specified page is captured.sleep=1000
uaSpecify the user agent. This option is useful when the page specified by url switches its display depending on the user agent of the accessing browser. Note: If the correct string is not sent, it may not switch as intended. Please confirm the specifications of the target website before using it.ua="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36"
formatSpecify the format of the file to be saved. pdf, png, jpeg, jpg, and webp are available.format="png"
cookieSpecify the URL that requires login to convert to PDF. Assumes the format of $smarty.cookies. Note: When using this plugin in batch processing, $smarty.cookies will be empty and cannot be used. Please use it in custom function as a pre-process or post-process of an API endpoint.cookie=$smarty.cookies
domainSpecify the domain of the cookie.domain="www.diverta.co.jp"
overwriteSpecify whether to overwrite the file if it already exists.overwrite=1
callback_batchSpecify the slug name of the batch processing if you want to execute Kuroco's batch processing after the PDF is generated.callback_batch="my_callback_batch"
dataYou can specify other parameters. This parameter is passed to the above batch processing.data=$smarty.request.data

Example

{generate_pdf
url="https://www.diverta.co.jp"
path="files/g/private/sample.pdf"
cookie=$smarty.cookies
domain="www.diverta.co.jp"
}

Related document
Refer to Scheduled generation of screenshot PDFs of external sites for the detail of how to use generate_pdf.

get_file

Gets a file from S3, GCS, external URL, etc.

Attributes

ParamTypeDescription
varStringVariable name to store the result
pathStringPath to the file on S3/GCS to retrieve
urlStringURL of the file to retrieve
bucketStringBucket name on S3/GCS where the file to retrieve is located
saveBooleanWhether to save the retrieved file in Kuroco's temporary area. If set to false, the content of the file is saved to the variable specified by var without saving it.
save_pathStringFile name to save the retrieved file

Example

{get_file path=$path}
{get_file url="https://www.diverta.co.jp/RSS.rdf" save_path="/files/user/rss/RSS.rdf" var="temp"}
{get_file url="https://www.diverta.co.jp/RSS.rdf" var="temp_file" save=false}
{if $temp_file|strlen>0}
File found
{else}
File not found
{/if}

github_deploy

Build and deploy front-end through integration with GitHub.

Attributes

ParamTypeDescription
result_varStringtrue: success false: failure

Example

{github_deploy result_var='res'}

googleanalytics

Get data from Google Analytics and set values in the counter table.
When passing the content ID to the sync_counter batch processing with the Smarty plugin of batch, you can apply the set values to the content.

Attributes

ParamTypeDescription
varStringVariable name to assign data retrieved from Google Analytics
updated_topics_idsArrayAn array of content IDs where counter values have been set
update_column_slugStringSlug of the column to update.
update_column_indexIntegerIndex of the column to update.
update_target_metricStringMetric to use for update.
update_target_dimensionStringCustom dimension to update.
topics_group_idIntegerContent definition ID.
startDateStringStart date of the aggregation period. Can be interpreted by PHP's strtotime().Default value is a 7 days before.
endDateStringEnd date of the aggregation period. Can be interpreted by PHP's strtotime().Default value is today.
queriesStringDirectly specify the query.

Example

{googleanalytics
var="result"
update_column_slug="pv"
update_target_dimension="customEvent:slug"
updated_topics_ids='updated_topics_ids'
topics_group_id=1}

{assign_array var=ext_data values=''}
{assign var=ext_data.topics_ids value=$updated_topics_ids}
{batch module='topics' name='sync_counter' ext_data=$ext_data}

gzip

Compresses a file with gzip and uploads it to cloud storage.

Prerequisites
To use gzip, you need to integrate it with Firebase. Refer to Cloud storage integration with Firebase for integration.

info

The destination path (dest) must be a GCS path (/files/g/). KurocoFiles paths (/files/user/, /files/temp/, /files/ltd/) are not supported for the destination.

Attributes

ParamTypeDescription
file_urlStringThe path to the file to be compressed. Must be a GCS path (/files/g/) or a URL starting with https://. KurocoFiles paths (/files/user/, /files/temp/, /files/ltd/) are not directly supported, but you can use the public URL of a KurocoFiles file (e.g., https://[site].g.kuroco-img.app/files/user/...). (required)
destStringThe path to save the gzip file. Must be a GCS path (/files/g/).
bucketStringThe name of the bucket. If omitted, the storage specified in [External System Integration] - [Firebase] is used.
callback_batchStringThe identifier of the batch processing to be called back after the gzip compression is complete.
dataMixedAny data. Passed to the callback batch.

Output Variables

VariableDescription
gzip_destThe path where the gzip file is saved. This variable is automatically assigned after execution.

Example

{gzip
file_url='https://[site].g.kuroco-img.app/files/user/data.csv'
dest='/files/g/public/data.csv.gz'
}
{gzip
file_url='/files/g/private/test/image.png'
dest='/files/g/public/test/image.gz'
callback_batch='gzip_complete_handler'
data=$callback_data
}

html5_check

Validates HTML5 syntax. Performs HTML5 syntax checking on the specified HTML content and stores detailed information in a variable if there are any errors.

Attributes

ParamTypeDescription
htmlStringHTML content to validate (required)
varStringVariable name to store error results (default: 'html5_errors')

Example

{html5_check html=$html_content var="myErrors"}
{if $myErrors|@count > 0}
{foreach from=$myErrors item=error}
<p>{$error}</p>
{/foreach}
{/if}

implode

Joins array elements into a string using a delimiter. PHP7-compatible with flexible argument order.

Attributes

ParamTypeDescription
value1String or ArrayEither the separator string or the array to join (Required)
value2String or ArrayEither the array to join or the separator string (Optional, default null)

Returns

A string with all array elements joined by the delimiter. Returns an empty string '' if the array is null or empty. Returns null if the arguments don't match any supported pattern.

Example

{* Standard argument order: separator|implode:array *}
{assign var='arr' value='["1","2","3"]'|json_decode}
{','|implode:$arr} {* Output: '1,2,3' *}

{* Omit separator (joins with empty string) *}
{$arr|@implode} {* Output: '123' *}

{* Legacy PHP7-compatible order: array|@implode:separator *}
{$arr|@implode:','} {* Output: '1,2,3' *}

{* Separator with null array (returns empty string) *}
{','|implode:null} {* Output: '' *}

Notes:

  • Supports both standard (separator|implode:array) and legacy PHP7-compatible (array|@implode:separator) argument orders.
  • Use the @ modifier when passing an array as the first argument to prevent Smarty from iterating over it.

in_array

Checks if a value exists in an array. PHP7-compatible with safe type handling.

Attributes

ParamTypeDescription
haystackArrayThe array to search in (Required)
strictBooleanUse strict type comparison (===) when true (Optional, default false)

Returns

true if the value is found in the array, false otherwise. Returns false if haystack is not an array.

Example

{* Basic usage *}
{if $value|in_array:$array}Value exists{/if}

{* With strict type comparison *}
{if $value|in_array:$array:true}Value exists (strict){/if}

{* Safe even if $array might not be an array *}
{if "apple"|in_array:$fruits}Apple is in the list{/if}

Notes:

  • Returns false safely when haystack is not an array, instead of raising an error.
  • Loose comparison by default; pass true as the third argument for strict comparison.

increment_counter

Increments the value of the counter type extended column of content by adding the specified value to the current value.

Attributes

ParamTypeDescription
varStringThe variable name to store the result after increment.
valueIntegerThe value to add (Required)
topics_group_idIntegerContent definition ID (Required)
slugStringTarget content's ID/Slug (Required)
ext_slugStringTarget column's ID/Slug (Required)
indexIntegersequence number of the repeating column starting from 0

Example

{increment_counter
var='result'
value=3
topics_group_id=10
slug='a-content'
ext_slug='a_col_slug'
index=0
}

indent

Indents lines of text.

Attributes

ParamTypeDescription
charsIntegerNumber of indentation characters (Optional, default 4)
charStringCharacter used for indentation (Optional, default " ")

Returns

The indented string.

Example

{$code|indent}
{$text|indent:8}
{$html|indent:2:"\t"}

Notes:

  • Indents at the beginning of every line (including the first), using a multiline regex to match all line starts.
  • Works with any character, not just spaces — useful for tabs or other prefixes.

join

Joins array elements into a string using a delimiter. This is an alias for the implode modifier with identical functionality.

Attributes

ParamTypeDescription
value1String or ArrayEither the separator string or the array to join (Required)
value2String or ArrayEither the array to join or the separator string (Optional, default null)

Returns

A string with all array elements joined by the delimiter. Returns an empty string '' if the array is null or empty. Returns null if the arguments don't match any supported pattern.

Example

{* Standard argument order: separator|join:array *}
{assign var='arr' value='["1","2","3"]'|json_decode}
{','|join:$arr} {* Output: '1,2,3' *}

{* Omit separator (joins with empty string) *}
{$arr|@join} {* Output: '123' *}

{* Legacy PHP7-compatible order: array|@join:separator *}
{$arr|@join:','} {* Output: '1,2,3' *}

{* String input (returns the string as-is) *}
{assign var='str' value='foo'}
{$str|join} {* Output: 'foo' *}

Notes:

  • join simply delegates to implode; both argument orders are supported, and the @ prefix should be used when passing an array as the first argument.

json_decode

Decodes a JSON string into a PHP value.

Attributes

ParamTypeDescription
assocBooleanWhen true, return associative arrays instead of objects (Optional, default true)

Returns

The decoded value. By default, JSON objects are returned as associative arrays. Returns null if the input is not a string or the JSON is invalid.

Example

{* Basic usage - returns associative array by default *}
{assign var='data' value='{"name":"John","age":30}'|json_decode}
{$data.name} {* Output: John *}

{* Decode JSON array *}
{assign var='items' value='["apple","banana","orange"]'|json_decode}
{$items[0]} {* Output: apple *}

{* Return as object instead of array *}
{assign var='obj' value='{"name":"John"}'|json_decode:false}
{$obj->name} {* Output: John *}

Notes:

  • Returns associative arrays by default (assoc defaults to true), unlike PHP's native json_decode().
  • Returns null if the input is not a string, or if the JSON is invalid — useful for parsing JSON received from APIs or stored in database fields.

logger

Logs to info.log. You can check it by going to [Operations]->[Log Management]->[Custom Log].

Attributes

ParamTypeDescription
msg1StringString 1(within 1KB)
msg2StringString 2(within 1KB)
msg3StringString 3(within 1KB)
msg4StringString 4(within 1KB)

Example

{logger msg1=$log1 msg2=$log2}

login

Log in.

Attributes

ParamTypeDescription
member_idIntegerMember ID
overwriteBooleanWhether to overwrite the current session if already logged in (i.e. login again).

Example

{login member_id=2 overwrite=false}

logout

Log out.

Attributes

None.

Example

{logout}

lottery

Lottery function.

Attributes

ParamTypeDescription
varStringThe variable name to store the result (required)
cntIntegerThe number of IDs to be drawn
duplicateIntegerThe number of duplicates
idsArrayTarget IDs (required)
exclude_idsArrayExcluded IDs

Example

{lottery
var='foo'
cnt=3
duplicate=0
ids=$ids
exclude_ids=$exclude_ids}

lower

Converts a string to lowercase.

Example

{"HELLO"|lower}        {* hello *}
{$name|lower}
{"ABC123"|lower} {* abc123 *}

Notes:

  • Uses PHP strtolower() directly and is NOT multibyte-safe — for UTF-8 input, use strtolower (which adds type guards) or PHP's mb_strtolower().

mb_truncate

Truncates a string to the specified length (multibyte-safe).

Attributes

ParamTypeDescription
lengthIntegerMaximum length (Optional, default 80)
etcStringString to append when truncated (Optional, default '...')
break_wordsBooleanBreak in the middle of words (Optional, default false)
middleBooleanTruncate from the middle (Optional, default false)

Returns

The truncated string.

Example

{$long_text|mb_truncate:50}
{$text|mb_truncate:30:"...":true}
{$string|mb_truncate:100:"[more]":false:true}

Notes:

  • Uses mb_strlen/mb_substr, so it is safe for UTF-8 and other multibyte encodings.
  • The etc suffix length is included in the final output length; when middle=true, the first and last halves are kept and joined by etc.
  • If the string is already shorter than length, it is returned unchanged. length=0 returns an empty string.

mbtruncate

Truncates a string with multibyte-character support. Internally delegates to the rcms_mbtruncate() function.

Attributes

ParamTypeDescription
lengthIntegerMaximum length of the result (Optional, default 80)
etcStringSuffix appended when truncated (Optional, default '...')

Returns

The truncated string with the optional suffix appended when truncation occurs.

Example

{* Default (80 chars, '...' suffix) *}
{$long_text|mbtruncate}

{* Custom length *}
{$text|mbtruncate:50}

{* Custom length and suffix *}
{$text|mbtruncate:100:'...more'}

{* No suffix *}
{$text|mbtruncate:50:''}

Multibyte characters (Japanese, Chinese, Korean, etc.) are handled correctly and are never cut in the middle of a character.

msgpack_pack

Converts data to MessagePack binary format.

Note: Since this is a modifier applied to an array, you need to prefix it with @. Scalar values (such as strings or numbers) can also be packed, but please note that msgpack_unpack only returns data when the decoded result is an array or an object, so scalar values cannot be unpacked.

Attributes

PositionTypeDescription
targetMixedThe data to convert (required). Must consist only of null, scalar (int, float, bool, string), array, or stdClass object.

Example

{assign_array var='data' values="test,1234"}
{assign var='packed' value=$data|@msgpack_pack}

Return Value

Returns the MessagePack binary data on success, or false if the input data contains invalid types (such as resources or custom objects) or if encoding fails.

msgpack_unpack

Decodes MessagePack binary data back to an array or object.

Note: This modifier only returns data if the decoded result is an array or object. If the original packed data was a scalar value (string, number, etc.), false will be returned.

Attributes

PositionTypeDescription
targetStringThe MessagePack binary to decode (required).

Example

{assign_array var='data' values="test,1234"}
{assign var='packed' value=$data|@msgpack_pack}
{assign var='unpacked' value=$packed|msgpack_unpack}

{$data|@debug_print_var}
{$unpacked|@debug_print_var}

Return Value

Returns the decoded data (array or object) on success, or false if the input is not a valid string, if decoding fails, or if the decoded result is not an array or object.

nl2br

Converts newlines to HTML <br> tags.

Returns

A string with <br /> tags inserted before each newline.

Example

{$text|nl2br}
{"Line 1\nLine 2"|nl2br}
{* Output: Line 1<br />
Line 2 *}

Notes:

  • Uses PHP's nl2br() directly, which inserts <br /> before \r\n, \r, and \n but keeps the original newline characters.
  • Each newline in a run of consecutive newlines gets its own <br /> tag.

pg_dateformat

Format the date and time based on the format. Please specify the format embedded by DateTimeInterface::format(). The three-letter notations for days of the week and months are converted to their respective language representations by the latest locale.

Attributes

PositionTypeDescription
1Stringformat

Example

{"2024-06-01 12:34:56"|pg_dateformat}
{"2024-06-01 12:34:56"|pg_dateformat:"Y-m-d(D) [H:i:s]"}
{"2024-05-01 12:34:56"|pg_dateformat:'M'}
{"-2 days"|pg_dateformat}
{"-1 hour"|pg_dateformat}

Output

2024/06/01(Sat) 12:34
2024-06-01(Sat) [12:34:56]
May
2024/06/19(Wed) 15:45
2024/06/21(Fri) 14:45

pg_dateformat2

Format the date and time based on the format. Please specify the format embedded by DateTimeInterface::format(). The three-letter notations for days of the week and months are converted to their respective language representations by the latest locale. Also, if the target date and time is within 24 hours, it will be converted to H:i:s(Updated s seconds ago) in HTML format. If this conversion is not necessary, please use pg_dateformat.

Attributes

PositionTypeDescription
1Stringformat

Example

{"2024-06-01 12:34:56"|pg_dateformat2}
{"2024-06-01 12:34:56"|pg_dateformat2:"Y-m-d(D) [H:i:s]"}
{"2023-05-01 12:34:56"|pg_dateformat2:'M'}
{"-2 days"|pg_dateformat2}
{"-1 hour"|pg_dateformat2}

Output

2024/06/01(Sat) 12:34
2024-06-01(Sat) [12:34:56]
May
2024/06/19(Wed) 15:45
<span style="color:#5FAF23;font-weight:bold;">14:45:51(Updated 1 hours ago)</span>

property_exists

Checks whether a property exists on an object or class.

Attributes

ParamTypeDescription
propertyStringThe property name to check (Required)

Returns

true if the property exists, false otherwise. Returns false if the property name is not a string, or if the first argument is neither an object nor a string (class name).

Example

{* Check for a property on an object *}
{if $object|property_exists:'name'}Object has name property{/if}

{* Check using a class name *}
{if 'MyClass'|property_exists:'staticProperty'}Class has static property{/if}

The object (or class name) is the modifier input and the property name is the argument. The check considers existence only — a property whose value is null is still treated as existing.

purge_cdn_cache

Purge (delete) the CDN cache.

Attributes

ParamTypeDescription
api_endpointStringSpecify the URL of the endpoint.
moduleStringSpecify the module name. Currently, it supports topics and csvtable and all (required).
topics_group_idintIf the module name is specified as topics, specify the content definition ID.
csvtable_idintIf the module name is specified as csvtable, specify the ID of the master.

Example

{purge_cdn_cache api_endpoint='/rcms-api/1/list'}
{purge_cdn_cache module='all'}
{purge_cdn_cache module='topics' topics_group_id=123}
{purge_cdn_cache module='csvtable' csvtable_id=123}

put_file

Uploads a file to KurocoFiles or S3/GCS storage.

Attributes

ParamTypeDescription
tmp_pathStringThe path of the file to upload. Specify a file in the temporary folder.
pathStringThe destination path of the file.
valueStringThe content to write to the file.
files_pathStringThe path on KurocoFiles (/files/(user
bucketStringThe name of the S3/GCS bucket to upload to.

Example

{put_file tmp_path=$tmp_path path=$upload_path}

rcms_arsort

Sorts an array in descending order while maintaining the relationship between associative keys and elements.
Note: This is a modifier for an array, so the "@" symbol must be used as a prefix.

Attributes

None.

Example

{assign var="result_arr" value=$input_arr|@rcms_arsort}

rcms_asort

Sorts an array in ascending order while maintaining the relationship between the associative key and its corresponding value.
Note: This is a modifier for arrays, so it needs to be preceded by the "@" symbol.

Attributes

None.

Example

{assign var="result_arr" value=$input_arr|@rcms_asort}

rcms_encrypt

You can encrypt and decrypt a specified string using the encryption key.
Data encrypted on a site with a different site key cannot be decrypted.

Attributes

ParamTypeDescription
varStringVariable name to assign result (optional)
actionString'encrypt' or 'decrypt' (required)
dataStringData string to encrypt/decrypt (required)
keyStringEncryption key (required) - Please use the value of the secret in principle.
sanitizeBooleanWhether to sanitize decrypted data (default: true)

Example

{secret var='secret_key' key='secret_key'}
{rcms_encrypt var='encrypted_value' action='encrypt' data=$plaintext key=$secret_key}
{rcms_encrypt var='decrypted_value' action='decrypt' data=$encrypted_value key=$secret_key}

rcms_file_size

Returns the size of the specified file.

Attributes

PositionTypeDescription
1IntegerThe format type of the result (default=1).
  • 0: Display value only
  • 1: Display with appropriate unit
2IntegerThe precision of the result in decimals (default=2).

Example

{$row.path|rcms_file_size}

rcms_hash

Calls the hash function.

Attributes

ParamTypeDescription
varStringName of the variable to store the result (required)
algoStringAlgorithm (default=sha256)
dataStringTarget string (required)
keyStringSecret key for HMAC method
binaryBooleanWhen set to true, the result is stored in binary form.

Example

{rcms_hash var='foo' data='hoge' key='salt'}

rcms_in_array

A plugin that eliminates the need to write is_array in Smarty when using in_array.

Attributes

PositionTypeDescription
1Arraylist

Example

{assign_array var=fruits values="apple,banana,orange"}
{if 'beef'|rcms_in_array:$fruits}
{assign var=message value='beef is fruits.'}
{else}
{assign var=message value='beef is not fruits.'}
{/if}

rcms_json_encode

Encodes a value as JSON with Unicode support, with special handling for RCMS content boundaries.

Returns

A JSON-encoded string containing unescaped Unicode characters.

Example

{* Basic usage *}
{$array|rcms_json_encode}

{* Use in JavaScript *}
<script>
var data = {$data|rcms_json_encode};
</script>

{* Encode an object *}
{$user_data|rcms_json_encode}

Uses the JSON_UNESCAPED_UNICODE flag so multibyte characters (e.g. Japanese) are preserved as-is. Strings containing the __RCMS_CONTENT_BOUNDARY__ marker are automatically split with explode2() into arrays before encoding.

rcms_krsort

Sorts the array in reverse order by key.

Note: This is a modifier for arrays, so it must be prefixed with '@'.

Attributes

None.

Example

{assign var="result_arr" value=$input_arr|@rcms_krsort}

rcms_ksort

Sorts the array in order by key.

Note: This is a modifier for arrays, so it must be prefixed with '@'.

Attributes

None.

Example

{assign var="result_arr" value=$input_arr|@rcms_ksort}

rcms_match

Calls the preg_match function.

Attributes

ParamTypeDescription
varStringThe variable name to store the result (required)
patternStringThe pattern to search for
subjectStringThe input string
flagsIntegerYou can specify the combination of the following flags.
256 - PREG_OFFSET_CAPTURE: If this flag is set, the offset of each match in bytes will also be returned. Be careful to change the value of var to an array. All elements of the array consist of the string matched at offset 0 and the offset to the subject at offset 1 of the string.
512 - PREG_UNMATCHED_AS_NULL: When this flag is passed, the unmatched subpattern is reported as null. If not passed, it is reported as an empty string.
offsetIntegerThe starting position of the search. Default is from the beginning.

Example

{rcms_match
var='foo'
pattern='/^ex+/'
subject='example'
flags=256}
{rcms_match
var='foo'
pattern='/^ex+/'
subject='example'
flags=512
offset=2}

rcms_match_all

Calls the preg_match_all function.

Attributes

ParamTypeDescription
varArrayThe variable name to store the result (required).
patternStringThe string representing the pattern to search for.
subjectStringThe input string.
flagsIntegerYou can specify a combination of the following flags:
1 - PREG_PATTERN_ORDER: If you specify the variable name as $matches, $matches[0] is an array of strings that matched the entire pattern, $matches[1] is an array of strings that matched the first subpattern, and so on.
2 - PREG_SET_ORDER: $matches[0] is an array of values captured by the first match, $matches[1] is an array of values captured by the second match, and so on.
256 - PREG_OFFSET_CAPTURE: If you set this flag, the offset of each match will also be returned (in bytes). Note that you should change the value of var to an array. All elements of that array will consist of the string matched at offset 0 and the offset into subject at offset 1.
512 - PREG_UNMATCHED_AS_NULL: If this flag is passed, any subpatterns that did not match will be reported as null. If this flag is not passed, they will be reported as an empty string.
offsetIntegerThe start position of the search. The default is the beginning.

Example

{rcms_match_all
var='matches'
pattern='|<[^>]+>(.*)</[^>]+>|U'
subject='<b>example: </b><div align=\"left\">this is a test</div>'
flags=2}

{$matches|@debug_print_var}

Output

Array (2)
0 => Array (2)
0 => "<b>example: </b>"
1 => "example:"
1 => Array (2)
0 => "<div align=\"left\">this is a test</div>"
1 => "this is a test"

rcms_rsort

Sorts an array in descending order.

Note: This is a modifier for an array, so you need to prefix it with "@".

Attributes

None.

Example

{assign var="result_arr" value=$input_arr|@rcms_rsort}

rcms_sort

Sorts an array in ascending order.

Note: This is a modifier for an array, so you need to prefix it with "@".

Attributes

None.

Example

{assign var="result_arr" value=$input_arr|@rcms_sort}

rcms_sort_by_key

Sorts an associative array by the value of a specified key.

Example

{assign var="product_list" value=$product_list|@rcms_sort_by_key:'price':'asc'}

rcms_strip_tags

Removes HTML and PHP tags from a string.

Example

{assign var="output" value=$input|rcms_strip_tags:'<br>'}

read_dir

Get a list of files that exist in KurocoFiles and repeat.

Attributes

ParamTypeDescription
nameStringThe name used to identify the read_dir block.
file_varObjectThe Smarty variable name to store the following file information:
- path: File path
- size: File size (in bytes)
- ctime: File content modification date (timestamp)
- mtime: File attribute (e.g., file name) modification date (timestamp)
- is_dir: Whether it's a directory or not.
pathStringThe path of the target directory to retrieve. Specify either /files/user or /files/ltd as subdirectories.
patternStringIf you want to filter by file path, specify a regular expression here.
recursiveBooleanWhen set to true, it will recursively retrieve the contents of subdirectories.
name_onlyBooleanWhen set to true, the file_var variable will return only the file path as a string.
typeStringSpecify 'file' or 'dir' to iterate over files only, directories only, or both if not specified.

Example

{read_dir name="hoge" file_var='file' path='/files/user'}
{$file|@debug_print_var}
{/read_dir}

read_file

Reads a file line by line and iterates through it.

Attributes

ParamTypeDescription
nameStringName to identify the read_file block.
pathStringpecify the file path as a relative path from /files/. The accessible directories are as follows:
  • /files/user/
  • /files/ltd/
  • /files/topics/
  • /files/member/
rowStringSmarty variable to store one line of read data.
typeStringFile format. Specify 'txt', 'csv', or 'jsonl'. If not specified, the default is 'txt'.
ignore_permissionBooleanIf the /files/topics/ or /files/member/ directory is specified and true is set, the file will ignore the publication status and permission settings of the saved content.

Example

{read_file name="hoge" path='foo.txt' row="row"}
{$row|escape}
{/read_file}

refresh_cs

Resets the custom member filter (MemberCustomSearch).

Attributes

ParamTypeDescription
addArrayArray of MemberCustomSearch IDs to be added.

Example

{refresh_cs}
{assign_array var="custom_search_ids" values="1,2,3"}
{refresh_cs add=$custom_search_ids}

regex_replace

A regular expression search and replace on a variable.

Attributes

PositionTypeDescription
1StringThis is the regular expression to be replaced.
2StringThis is the string of text to replace with.

Example

{assign var="string" value="This is KUROCO."}
{$string|regex_replace:"/kuroco/i":"Kuroco"}

{assign var="string" value="12,31,2023"}
{$string|regex_replace:'/(\d+),(\d+),(\d+)/':'$3-$1-$2'}

{assign var="string" value="本日は晴天なり"}
{$string|regex_replace:"/晴天/":"雨天"}

Output

This is Kuroco.

2023-12-31

本日は雨天なり

remove_dir

Removes a directory.

Attributes

ParamTypeDescription
pathStringPath of the directory to remove.
status_varStringName of the Smarty variable that will hold the result of the removal.

Example

{remove_dir path='/files/user/hoge' status_var='status'}

remove_file

Removes files.

Attributes

ParamTypeDescription
pathStringThe path of the file to be deleted
bucketStringThe name of the S3/GCS bucket where the file is located
status_varStringThe name of the Smarty variable to store the deletion result

Example

{remove_file path='/files/user/hoge.jpg' status_var='status'}

rename_file

Moves file.

Attributes

ParamTypeDescription
src_pathStringSource path
dest_pathStringDestination path

Example

{rename_file src_path=$src_path dest_path=$dest_path}

replace

Simple string search and replace.

Attributes

ParamTypeDescription
searchString/ArrayString(s) to search for (Required)
replaceString/ArrayReplacement string(s) (Required)

Returns

The modified string with replacements applied.

Example

{$text|replace:"old":"new"}
{$path|replace:"\\":"/"}
{"Hello World"|replace:"World":"Everyone"}

Notes:

  • Uses PHP str_replace() — literal (non-regex), case-sensitive replacement of all occurrences. Use regex_replace for case-insensitive matching.
  • Search/replace can be arrays to perform multiple substitutions in a single call.

return

Exits the custom function with an optional value.

Attributes

ParamTypeDescription
valueMixedA value to return to the calling custom function.

Example

To return a value from a custom function called "sub_function":

{return value="Hello"}

To call sub_function in the different custom function:

{function name="sub_function" var="result"}

The value "Hello" is stored in $result variable.

save_file

Save as file.

Attributes

ParamTypeDescription
valueStringContent to be saved.
varStringVariable name to store the result.

Example

{save_file var='path' value=$value}

secret

Retrieves a secret.

Attributes

ParamTypeDescription
varStringThe variable name to store the result (required)
keyStringThe name of the secret key (required)

Example

{secret var='foo' key='hoge'}

sendmail

Sends an email.
Additionally, the variables provided as arguments to sendmail can be used within the message template.

Attributes

ParamTypeDescription
varStringThe variable name to store the result. If successful, true will be stored; otherwise, false.
toStringThe destination email address.
You can specify multiple recipients separated by commas.
Example:to="test1@example.com, test2@example.com
to_member_idIntegerThe destination member id.
You can specify multiple recipients separated by commas.
Example:to_member_id="1,2"
subjectStringThe email subject.
contentsStringThe email body.
fromStringThe FROM address.
from_nmStringThe sender name of the FROM address.
ccStringEmail addresses to be specified in CC. If multiple addresses are specified, separate them with commas.
cc_member_idIntegerMember IDs to be specified in CC. If multiple IDs are specified, separate them with commas.
bccStringEmail addresses to be specified in BCC. If multiple addresses are specified, separate them with commas.
bcc_member_idIntegerMember IDs to be specified in BCC. If multiple IDs are specified, separate them with commas.
mail_templateStringThe identifier of the message template.
Variable NameStringSpecifies the variables to pass to the message template.

Example1

{sendmail
var='result'
to=$mail_to
subject='testmail'
contents="This is test."
from="test@example.com"
from_nm="test"}

Example2

By doing the following, you can use the variable $member_detail in the message template.

{sendmail
var=result
to=$mail_to
subject='testmail'
mail_template='update_test'
member_detail=$member_detail
from="noreply@kuroco-mail.app"
from_nm="test"}

set_memory

Increases the memory allocation.

Attributes

ParamTypeDescription
varStringThe specified memory capacity. Must be either 256M, 512M, or 768M.

Example

{set_memory memory_limit='256M'}

site_sync

Synchronize between sites. A 6-hour interval is required since the last time this plugin was performed.

Attributes

ParamTypeDescription
from_site_keyStringSite key of synchronization source
to_site_keyStringSite key of synchronization destination
If no specific designation is provided, it will synchronize with your own website.
sync_typeInteger1:Sync App design 2:Full sync 4:Sync App design (excluding tags)

Example

{site_sync from_site_key='from_example_key' to_site_key='to_example_key'  sync_type='1'}

slack_get_message

Gets a message from Slack.

Attributes

ParamTypeDescription
varStringThe variable name to store the result in.
channelStringThe ID of the channel.
tsStringThe timestamp value of the message.

Example

{slack_get_message
var='message'
channel='XXXXXXXXX'
ts='1675411163.005300'}

slack_post_message

Sends a message to Slack.

Attributes

ParamTypeDescription
varStringThe name of the variable to store the result. If successful, it will store true, otherwise false.
channelStringThe ID of the channel to post the message to.
usersArrayAn array of user IDs to mention in the message.
textStringThe text of the message.
thread_tsStringThe timestamp of the parent message in the thread.

Example

{slack_post_message
channel='XXXXXXXXX'
users=$users
text='test'}

slack_team_info

Get information about a Slack team.

Attributes

ParamTypeDescription
varArrayThe variable name to store the result. If the process fails, false is stored.
teamStringThe search condition.

Example

{slack_team_info var='team' team=$team}

sleep

Delays the execution. Delay time can be set from a minimum of 100ms to a maximum of 1000ms.

Attributes

ParamTypeDescription
msIntegerTime to stop in milliseconds. Must be greater than or equal to 100 and less than or equal to 1000.
If a value outside this range is specified, the time is set to either 100ms or 1000ms.

Example

{sleep ms=300}

sort_name

Displays the last name and first name swapped when the language setting is set to English ('en').

Example

{'Yamada'|sort_name:'Taro'}
// If the language setting is set to 'en', 'Taro Yamada' will be displayed.
// Otherwise, 'Yamada Taro' will be displayed.

spacify

Inserts a separator (a single space by default) between each character.

Attributes

ParamTypeDescription
spacify_charStringString inserted between characters (Optional, default ' ')

Returns

The spacified string.

Example

{"Hello"|spacify}      {* H e l l o *}
{$text|spacify:"-"} {* H-e-l-l-o *}
{"Test"|spacify:"_"} {* T_e_s_t *}
{"ABC"|spacify:" - "} {* A - B - C *}

Notes:

  • The separator can be multiple characters, not just a single character.
  • NOT multibyte-safe — splits on bytes, which may break multibyte characters apart.

split

Splits a string into an array using a delimiter. Supports both regular-expression and literal delimiters.

Attributes

ParamTypeDescription
stringString/NumberThe string to split (Required)

Returns

An array of strings. Returns an empty array [] if the string is empty or not a valid type.

Example

{* Basic split with literal delimiter *}
{','|split:$csv_string}

{* Split by regex pattern (must start with /) *}
{'/\s+/'|split:$text} {* Split on whitespace *}

{* Split a number (auto-converted to string) *}
{'-'|split:12345}

The delimiter is the modifier input and the string is passed after the colon. If the delimiter begins with / and is at least three characters long, it is treated as a regex and run through preg_split(); otherwise the value is split with explode2().

storage_url

Get a signed URL to read a file from S3/GCS.

Attributes

ParamTypeDescription
varStringName of the variable to store the result.
pathStringPath of the file on S3/GCS.
expireStringExpiration time of the URL. Default is '+167 hour'.

Example

{storage_url path=$path var='url' expire="+1 hour" }

string_format

Formats a string using sprintf().

Attributes

ParamTypeDescription
formatStringsprintf format string (Required)

Returns

The formatted string.

Example

{$number|string_format:"%02d"}        {* 05 *}
{$price|string_format:"$%.2f"} {* $19.99 *}
{$name|string_format:"Hello, %s!"} {* Hello, John! *}
{$hex|string_format:"%08X"} {* 0000FF00 *}

Supports the usual sprintf specifiers — %s, %d, %f, %e, %x/%X, %o, %b, %% — along with width, precision, and padding (e.g. %08d, %.2f, %-10s).

strip

Removes line breaks in the enclosed area and applies trim to each line.

Attributes

None.

Example

{* All of the following examples will be output on a single line *}
{strip}
{foreach from=$contents item=content name='loop1'}
{if $content.topics_group_id == 1}
{$content.subject}
{/if}
{if !$smarty.foreach.loop1.last}
,
{/if}
{/foreach}
{/strip}

strip_tags

Removes HTML tags from text.

Attributes

ParamTypeDescription
replace_with_spaceBooleanReplace tags with a space instead of removing them (Optional, default true)

Returns

The string without HTML tags.

Example

{$html|strip_tags}
{$html|strip_tags:false}
{"<p>Hello</p>"|strip_tags} {* " Hello " with spaces *}
{"<p>Hello</p>"|strip_tags:false} {* "Hello" no spaces *}
{"<b>A</b><i>B</i>"|strip_tags} {* "A B" *}
{"<b>A</b><i>B</i>"|strip_tags:false} {* "AB" *}

Notes:

  • When replace_with_space=true (default), all tags are replaced with a single space, preventing adjacent text from being concatenated (e.g. <b>Hello</b><i>World</i> becomes Hello World, not HelloWorld).
  • When replace_with_space=false, PHP's strip_tags() is used, which completely removes the tags. Content between tags is preserved either way.

strtodate

Get date from timestamp.

Attributes

ParamTypeDescription
varStringVariable name to store the result (required)
timestampInt|StringTimestamp
formatStringFormat

Example

{strtodate var='today' timestamp='today' format='Ymd'}

strtolower

Converts a string to lowercase, with type checking.

Returns

The lowercase string, or an empty string if the input is not a scalar.

Example

{"HELLO WORLD"|strtolower}   {* hello world *}
{$name|strtolower}
{$array|strtolower} {* returns empty string *}

Notes:

  • Non-scalar values (arrays, objects, null) return an empty string; the input is explicitly cast to string before processing.
  • NOT multibyte-safe — for UTF-8, use PHP's mb_strtolower(). Similar to lower, but with explicit non-scalar handling.

strtoupper

Converts a string to uppercase, with type checking.

Returns

The uppercase string, or an empty string if the input is not a scalar.

Example

{"hello world"|strtoupper}   {* HELLO WORLD *}
{$name|strtoupper}
{$array|strtoupper} {* returns empty string *}

Notes:

  • Non-scalar values (arrays, objects, null) return an empty string; the input is explicitly cast to string before processing.
  • NOT multibyte-safe — for UTF-8, use PHP's mb_strtoupper(). Similar to upper, but with explicit non-scalar handling.

substr

Returns a substring from the input string, with type checking.

Attributes

ParamTypeDescription
startIntegerStart position (0-based; can be negative) (Required)
lengthIntegerLength of the substring; can be negative (Optional, default null)

Returns

The substring, or an empty string if the input is not a scalar.

Example

{"Hello World"|substr:0:5}  {* Hello *}
{$text|substr:6} {* from position 6 to end *}
{$string|substr:-5:5} {* last 5 characters *}
{$text|substr:0:-3} {* all except last 3 characters *}
{$array|substr:0:5} {* returns empty string *}

Notes:

  • A negative start counts from the end of the string; a negative length omits that many characters from the end.
  • NOT multibyte-safe — counts bytes, not characters.

subtract

Subtracts a number from a variable.

Attributes

ParamTypeDescription
varStringThe variable name to store the result (required)
valueIntThe number to subtract from the variable.

Example

{subtract var='i' value=5}

sync_counter

Synchronizes the counter extension field values for content.

Counter fields improve performance by separating frequently updated values from the content itself and updating them asynchronously. By using this plugin, the asynchronously updated counter values are synchronized with the values in the content.

Attributes

ParamTypeDescription
idsArray/StringArray of target content IDs (required). Can also be specified as a comma-separated string.

Example

{sync_counter ids=1078}
{sync_counter ids="1,2,3"}

to_form_options

Converts an associative array to the format of [['key'=>$key, 'value'=>$value], ...].

Attributes

PositionTypeDescription
targetArrayThe array to be converted (required).

Example

{assign var='form_options' value=$options_array|@to_form_options}
{assign var='form_options' value=$options_array|@to_form_options:'key':'label'}

to_object

Converts an array to a stdClass object.

Attributes

PositionTypeDescription
targetArrayThe array to be converted (required).

Example

{assign var='foo' value=$bar|@to_object}

truncate

Truncates a string to the specified length (byte-based).

Attributes

ParamTypeDescription
lengthIntegerMaximum length (Optional, default 80)
etcStringString to append when truncated (Optional, default '...')
break_wordsBooleanBreak in the middle of words (Optional, default false)
middleBooleanTruncate from the middle (Optional, default false)

Returns

The truncated string.

Example

{$text|truncate:50}
{$long_string|truncate:30:"...":true}
{$text|truncate:100:"[more]":false:true}

Notes:

  • Uses byte-based strlen/substr and is NOT multibyte-safe — for UTF-8 or other multibyte encodings, use mb_truncate instead.
  • When break_words=false (default), truncation occurs at the nearest word boundary; when middle=true, the first and last halves are kept and joined by etc.

twitter_post_message

Sends a message to Twitter.

Attributes

PositionTypeDescription
varStringThe variable name to store the result.
textStringThe message to send.

Related Documents
To use this plugin, you need to set up various items under [External System Integration] - [Twitter]. For detailed instructions on setting up integration with Twitter and automatically posting to Twitter when posting content, see Setting up Twitter integration.

unzip

Unzips a zip file.

Prerequisites
To use unzip, you need to integrate it with Firebase. Refer to Cloud storage integration with Firebase for integration.

info

The destination path (dest) must be a GCS path (/files/g/). KurocoFiles paths (/files/user/, /files/temp/, /files/ltd/) are not supported for the destination. The source path (src) must be a URL starting with https:// or a GCS path (/files/g/). KurocoFiles paths are not directly supported, but you can use the public URL of a KurocoFiles file.

Attributes

ParamTypeDescription
srcStringThe path to the zip file to be extracted. Must be a URL starting with https:// or a GCS path (/files/g/). KurocoFiles paths (/files/user/, /files/temp/, /files/ltd/) are not directly supported, but you can use the public URL of a KurocoFiles file (e.g., https://[site].g.kuroco-img.app/files/user/...).
destStringThe path to the folder to store the extracted files. Must be a GCS path (/files/g/). KurocoFiles paths (/files/user/, /files/temp/, /files/ltd/) are not supported for the destination.
bucketStringThe name of the bucket. If omitted, the storage specified in [External System Integration] - [Firebase] is used.
callback_batchStringThe name of the batch processing to be called back after the zip extraction is complete.
dataMixedAny data. Passed to the callback batch.
overwriteIntegerWhether to overwrite the file with the same name in the destination folder if it already exists. 0 or 1.
detect_orderArrayYou can specify the priority order when determining the character encoding of the file name of the deployed file. By default, it is set to ["utf8", "cp932", "EUC-JP"].

Example

{unzip
src='/files/g/private/temp/zip/hoge.zip'
dest='/files/g/private/temp/unzip/'
overwrite=1
callback_batch='batch1'
}

update_counter

Updates the value of the counter type extended column of content.

Attributes

ParamTypeDescription
varStringThe variable name to store the result.
valueIntegerThe value you want to set (Required)
topics_group_idIntegerContent definition ID (Required)
slugStringTarget content's ID/Slug (Required)
ext_slugStringTarget column's ID/Slug (Required)
indexIntegersequence number of the repeating column starting from 0

Example

{update_counter
var='result'
value=3
topics_group_id=10
slug='a-content'
ext_slug='a_col_slug'
index=0
}

upper

Converts a string to uppercase.

Example

{"hello"|upper}        {* HELLO *}
{$name|upper}
{"abc123"|upper} {* ABC123 *}

Notes:

  • Uses PHP strtoupper() directly and is NOT multibyte-safe — for UTF-8 input, use strtoupper (which adds type guards) or PHP's mb_strtoupper().

usage_price_format

Formats a usage/price value for display using the RCMS_Usage formatting system.

Attributes

ParamTypeDescription
edge_flgBooleanEdge formatting flag, affecting decimal handling (Optional, default false)

Returns

The formatted price string. Returns an empty string "" if the input is an empty string.

Example

{* Basic price formatting *}
{$price|usage_price_format}

{* With edge flag enabled *}
{$price|usage_price_format:true}

{* Display a usage cost *}
{$monthly_cost|usage_price_format}

The actual formatting is delegated to RCMS_Usage::format_price(); the currency symbol, thousand separators, and decimal precision depend on the RCMS_Usage configuration.

uuid

Retrieves uuid.

Attributes

ParamTypeDescription
varStringVariable to store.

Example

{uuid var='foo'}

wordwrap

Wraps text to a specified line length.

Attributes

ParamTypeDescription
lengthIntegerLine width in characters (Optional, default 80)
breakStringString inserted as a line break (Optional, default "\n")
cutBooleanForce-break long words at the width (Optional, default false)

Returns

The wrapped string with line breaks inserted.

Example

{$text|wordwrap:40}
{$long_text|wordwrap:60:"<br>"}
{$url|wordwrap:50:"\n":true}
{$code|wordwrap:120:"<br />":true}

Notes:

  • When cut=false (default) long words are NOT broken and may exceed the line length; with cut=true, breaks occur exactly at the specified width, even inside a word.
  • The break string can be anything — useful for inserting HTML <br> tags. Existing line breaks in the input are preserved.

write_file

Writes data to a file.

Attributes

PositionTypeDescription
pathStringThe file path. If omitted, the file is automatically written to a temporary area with a unique file name.
varStringThe variable name to store the temporary file path that was written (required).
valueString | ArrayThe data to be written. If an array is specified, it will be written in CSV format.
is_appendIntegerAppend mode. 0 or 1. If in append mode, path must be specified.

Example

{write_file var="path" value="hoge"}
{write_file path=$path value="foo" is_append=1}
{write_file path=$path value="var" is_append=1}

xmltojson

Converts XML to JSON.

Attributes

ParamTypeDescription
varStringThe variable name to store the result. (required)
xmlStringThe XML to be converted.
convert_namespaceIntegerWhen specifying 1, elements including namespaces are also exported to JSON.

Example

{xmltojson var='json' xml='input'}

zip

Compresses files into a Zip file.

Prerequisites
To use zip, you need to integrate it with Firebase. Refer to Cloud storage integration with Firebase for integration.

info

The destination path (dest) must be a GCS path (/files/g/). KurocoFiles paths (/files/user/, /files/temp/, /files/ltd/) are not supported for the destination. The url in each entry must be a GCS path (/files/g/) or a URL starting with https://. KurocoFiles paths are not directly supported, but you can use the public URL of a KurocoFiles file.

Attributes

PositionTypeDescription
entriesArrayList of files to compress. Each entry must contain url (the file URL or GCS path) and name (the filename in the zip). The url must be a GCS path (/files/g/) or a URL starting with https://. KurocoFiles paths (/files/user/, /files/temp/, /files/ltd/) are not directly supported, but you can use the public URL of a KurocoFiles file (e.g., https://[site].g.kuroco-img.app/files/user/...).
destStringThe path of the zip file. Must be a GCS path (/files/g/). KurocoFiles paths (/files/user/, /files/temp/, /files/ltd/) are not supported for the destination.
bucketStringBucket name. If omitted, the Storage set up in [External System Integration] - [Firebase] will be used.
callback_batchStringBatch processing name to be called back after the Zip compression process is completed.
dataMixedAny data to be passed to the callback batch.

Example

{assign_array var='entries' values=''}

{assign_array var='entry1' values=''}
{append var='entry1' index='name' value='name1'}
{append var='entry1' index='url' value='https://xxxx/xxxx.jpg'}
{append var='entries' value=$entry1}

{assign_array var='entry2' values=''}
{append var='entry2' index='name' value='name2'}
{append var='entry2' index='url' value='https://xxxx/yyyy.jpg'}
{append var='entries' value=$entry2}

{zip entries=$entries dest='/files/g/public/a.zip' bucket=$bucket}

Support

If you have any other questions, please contact us or check out Our Slack Community.