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.
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
| Reference | Behavior in Kuroco |
|---|---|
$smarty.cookies | Disabled. Always evaluates to null. Read cookies on the server side instead. |
$smarty.env | Disabled. Always evaluates to null. |
$smarty.server | Allowed, 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_validate | Kuroco-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}
| Category | Allowed names |
|---|---|
| Functions | is_null, count, is_array, in_array, isset, is_object |
| Pseudo-constants accepted as bare words | null / 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:
- 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. - PHP-function pass-through — any function in Kuroco's
MODIFIER_FUNCSallow-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 isnull(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.
| Group | Functions |
|---|---|
| String / text | strlen, 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 text | mb_strlen, mb_substr, mb_strpos, mb_stripos, mb_strwidth, mb_strimwidth, mb_convert_kana, mb_convert_encoding |
| Array — read | is_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 / sort | array_push, array_pop, array_shift, array_merge, array_reverse, sort, rsort, ksort, krsort, asort, arsort, shuffle, implode, explode, join, unset |
| Number / cast | min, max, floor, round, intval, floatval, strval, is_numeric, mt_rand, number_format |
| Date / time | strtotime, rcms_strtotime |
| URL / encoding | parse_url, http_build_query, base64_encode, base64_decode, json_encode, filter_var, pathinfo |
| Misc / Kuroco helpers | html_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);
| Param | Values | Effect |
|---|---|---|
type | auto (default), str / string, int / integer, bool / boolean, float, array | Casts $value to the requested type before assignment. |
nullable | false (default) / true | When 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
| Shape | Recommended 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 returnsnull— 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
| Param | Type | Description |
|---|---|---|
| var | String | The variable name to which the addition is performed. The result of the addition is also stored in the same variable name. (required) |
| value | Int | Number |
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
| Item | Usage | Example | Note |
|---|---|---|---|
| endpoint | Endpoint (required) | https://example.com/brah/ | |
| method | Method | POST/GET/PATCH/PURGE/PUT/DELETE/HEAD | |
| query | Query string | param1=hoge¶m2=foo | |
| queries | Query array | $params | |
| json_body | Request JSON body | {param1:"hoge",param2:"foo"} | |
| body | Request body | ||
| files | File | ['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. |
| headers | Request headers | ['Host: localhost','user-agent: hoge'] | Specify as an array. |
| cache_time | Cache time (minutes) | 20 | |
| var | Storage variable of the response | response | |
| json_var | Storage variable of the response | response | If the response is in JSON format, the decoded value is stored. |
| resp_header_var | Response header storage variable | header | The response headers will be stored in an array format. |
| dl_flg | Download flag | true/false | If true, the response is saved as a file in the Kuroco temporary area. |
| status_var | 0: Failure 1: Success | status | Returns whether the request was successful or not. |
| timeout | Timeout | 60 | Specify the timeout (in seconds). |
| sslcert | secret key of mTLS client certificate | SSLCERT001 | Specify a Kuroco secret key of mTLS client certificate |
| sslkey | secret key of mTLS client secret key | SSLKEY001 | Specify a Kuroco secret key of mTLS client secret key |
| cainfo | secret key of mTLS Server CA info | CAINFO001 | Specify 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
| Param | Type | Description |
|---|---|---|
| endpoint | String | Endpoint (required) |
| method | String | Method (POST/GET) |
| query | String | Query string |
| queries | Array | Query array |
| headers | Array | Request headers |
| cache_time | Integer | Cache time (minutes) |
| var | String | Variable name to store the response |
| status_var | String | 0:Failed 1:Success |
| member_id | Integer | Execute as the specified login member *Note: Cannot be used in conjunction with the 'direct' parameter. |
| use_current_session | Boolean | Execute API request by taking over the current session |
| direct | Boolean | Execute 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
| Param | Type | Description |
|---|---|---|
| var | String | The variable name to store the result (required) |
| model | String | Model |
| method | String | Method (operation) |
| version | Integer | Version |
| request_params | Array | Request variables |
| method_params | Array | Method 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
| Param | Type | Description |
|---|---|---|
| var | String | The name of the array (required) |
| value | String | The name of the object or array to add (required) |
| index | Integer | The 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
| Param | Type | Description |
|---|---|---|
| array | Array | The 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
trueeven when the value isnull. - Returns
falseif 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
| Param | Type | Description |
|---|---|---|
| dg_key | String | The key to generate DG_CODE |
| dg_id | String | The id to generate DG_CODE |
| api_key | String | The key to generate sid request (required) |
| var | Array | The name of the returning array |
| jwt_data | Array | JWT data |
| member_id | Integer | Member ID |
| expire | Integer | Expiration 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
| Param | Type | Description |
|---|---|---|
| var | String | The name of the variable to assign the array to (required) |
| values | String | The values to store in the array. A string separated by a delimiter |
| delimiter | String | The delimiter to use to split the values specified in 'values'. The default is a comma |
| keys | String | If 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
| Param | Type | Description |
|---|---|---|
| var | String | Name of the assigned diff array |
| array1 | Array | Array 1 |
| array2 | Array | Array 2 |
| diff_mode | String | Mode 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
| Param | Type | Description |
|---|---|---|
| var | String | Name of the assigned intersect array |
| array1 | String | Array 1 |
| array2 | String | Array 2 |
| intersect_mode | String | Mode 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
| Param | Type | Description |
|---|---|---|
| var | String | The name of the return variable (required) |
| from | String | Original array |
| key | String | key name |
| value | String | value |
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
| Param | Type | Description |
|---|---|---|
| csvtable_id | Integer | The ID of the master (required) |
| var | String | The name of the return variable (required) |
| get_key_val | Boolean | Enable the use of optional parameters. (optional) |
| key_idx | Integer/Array | Return dimension or dimensions to be returned. (optional) |
| value_idx | Integer | Return dimension or dimensions to be returned. (optional) |
| multiple | Boolean | Distinguish by the number of dimensions. (optional) |
| lang | String | If it supports multiple languages, specify the language such as "ja", "en", etc. |
| filter | String | Specifies the filter condition.(optional) |
| allow_list | String | Specifies 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
| Param | Type | Description |
|---|---|---|
| module_type | String | The module name. Specify one of "topics","comment","member","tag","csvtable", or "ec_product". The default is "topics". |
| module_id | Integer | The ID of the specified module. |
| var | String | The name of the variable to store the result (required). |
| time | String | The strtotime format. |
| format | String | The 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
| Param | Type | Description |
|---|---|---|
| var | String | Variable name to store global variables. |
| key | String | Key for global variables. |
| value | Mixed | Value of the global variable. |
| unset | Bool | To 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
| Param | Type | Description |
|---|---|---|
| group_id | Integer | Group ID (required) |
| var | String | The name of the variable to store the result (required). |
| lang | String | The language code (e.g., "ja", "en"). |
Example
{assign_group_nm group_id=100 var='group_nm'}
assign_member_detail
Retrieve member's information.
Attributes
| Param | Type | Description |
|---|---|---|
| var | String | The name of the variable to store the result (Required) |
| member_id | Int | The member ID of the value to retrieve (Required)| |
| open_by_group | Boolean | When false, the viewing permission is ignored. The default value is true. |
| open_flg | Int | (Deprecated) When -1, only information about members who can view is retrievable. |
| assign_group_flg | Boolean | Whether 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
| Param | Type | Description |
|---|---|---|
| module_type | String | The name of the module. Specify one of "topics", "comment", "member", "tag", "csvtable", or "ec_product". The default is "topics". |
| module_id | Integer | The ID of the specified module. |
| var | String | The variable name to store the result (required). |
| cookie_flg | Integer | The flag for getting favorite contents with cookie management. |
| action_type | String | The 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
| Param | Type | Description |
|---|---|---|
| module_id | String | The ID of the module where the content is specified. |
| module_type | String | The name of the module. Specify either "topics", "comment", "member", "tag", "csvtable", or "ec_product". Default is "topics". |
| var | Boolean | The variable name to store the result (required). |
| new_order_flg | String | When set to false, the results are returned in ascending order. |
| cnt | String | Limits 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
| Param | Type | Description |
|---|---|---|
| module | String | Module name |
| module_id | Integer | ID in the specified module (required) |
| var | String | Variable name to store the result (required) |
| tag_category_id | Integer | If you want to narrow down by tag category, specify the tag category ID (optional) |
| tag_relation_list | Array | Array 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
| Param | Type | Description |
|---|---|---|
| var | String | The name of the variable to store the result in (required) |
| lang | String | Language code setting |
| tree_flg | Boolean | Flag 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
| Param | Type | Description |
|---|---|---|
| var | String | The name of the variable to store the result in (required) |
| category_id | Integer | The ID of the category tag to specify (required) |
| order | Array | An 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
| Param | Type | Description |
|---|---|---|
| var | String | The variable name to store the result (required). |
| topics_group_id | Integer | The topics_group_id of the category group to be specified (required). |
| lang | String | Language 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
| Param | Type | Description |
|---|---|---|
| var | String | Variable name to store the result (required) |
| topics_id | Integer | ID of the content (required) |
| lang | String | Language setting |
| chk_open_flg | Boolean | Whether 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
| Param | Type | Description |
|---|---|---|
| endpoint | String | Endpoint (required) |
| method | String | HTTP Method (POST/GET) |
| query | String | Query string |
| queries | Array | Query array |
| headers | Array | Request headers |
| files | Array | Uploaded files |
| var | String | Variable to store the response |
| status_var | String | 0: Failure 1: Success |
| member_id | Integer | Execute as the specified login member |
| use_current_session | Boolean | Execute 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
| Param | Type | Description |
|---|---|---|
| type | String | Specify "full" |
| memo | String | Memo for the backup |
| result_var | String | Variable 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
| Param | Type | Description |
|---|---|---|
| backup_id | String | Specify the backup ID |
| start_date | String | Specify the start date of the backup period to delete |
| end_date | String | Specify the end date of the backup period to delete |
| result_var | String | Variable 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
| Param | Type | Description |
|---|---|---|
| batch_id | Integer | Batch ID (Either this value or name is required) |
| name | String | Slug of batch (Either this value or batch_id is required) |
| module | String | Target module name (It used when you register default batch) |
| ext_data | Array | Data to pass to the registered batch. |
| var | String | Variable 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
| Param | Type | Description |
|---|---|---|
| uc_digits | Boolean | Capitalize 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=trueto 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
| Param | Type | Description |
|---|---|---|
| cat | Mixed | Value 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
| Param | Type | Description |
|---|---|---|
| site_key | String | Site key (required) |
| var | String | Name 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}
cookie
Get/set Cookie.
Attributes
| Param | Type | Description |
|---|---|---|
| var | String | Variable name |
| key | String | Key |
| value | String | String value |
| expires | Integer | Expiration date of the cookie in days |
| overwrite | Integer | Overwrite 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
0for empty arrays. - Unlike PHP's native
count(), this modifier returns0for non-array values instead of1.
count_characters
Counts the number of characters in text.
Attributes
| Param | Type | Description |
|---|---|---|
| include_spaces | Boolean | Include 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
0x80–0xff). - Pure punctuation sequences are not counted as words.
date
Assigns a date variable.
Attributes
| Param | Type | Description |
|---|---|---|
| var | String | Variable name to store the result (required) |
| time | String | strtotime format |
| format | String | Format |
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
| Param | Type | Description |
|---|---|---|
| format | String | Date format string (Optional, default 'Y-m-d') |
| default_date | String | Default 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 PHPdate()equivalents (%Y→Y,%m→m,%d→d,%H→H,%M→i,%S→s, etc.) before formatting.
debug_print_var
Formats a variable's contents for display in the debug console.
Attributes
| Param | Type | Description |
|---|---|---|
| depth | Integer | Current recursion depth (used internally; Optional, default 0) |
| length | Integer | Maximum 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 asClassName Object (count), booleans as<i>true</i>/<i>false</i>, andnullas<i>null</i>. - Special characters are rendered as HTML italics (
<i>\n</i>,<i>\r</i>,<i>\t</i>), strings are truncated viarcms_mbtruncate()with a...suffix, and output is HTML-escaped for safe display.
default
Provides a default value for empty variables.
Attributes
| Param | Type | Description |
|---|---|---|
| default | Mixed | Default 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
0andfalseare NOT considered empty — this differs from PHP'sempty().
detect_document_text
Detects (OCR) text from PDF/TIFF files using Google Cloud Vision API.
This plugin can only be executed in batch processing or in test mode on the admin panel.
Attributes
| Param | Type | Description |
|---|---|---|
| var | String | Variable name to store the result (required) |
| dir | String | File directory (e.g. /files/topics) (required) |
| file_nm | String | File name (required when module_id is not specified) |
| module_id | Integer | Module ID (required when file_nm is not specified) |
| ext_id | Integer | Extension item ID |
| no | Integer | File number (default: 0 for /files/topics, otherwise null) |
| lang | String | Language code |
| slug | String | Slug |
| type | String | Output format: "text" (default) or "array" |
| no_cache | Boolean | Disable cache (default: false) |
There are two ways to specify the target file:
- By file name: Specify
dirandfile_nm. - By module parameters: Specify
dirandmodule_id, along with optional parameters such asext_id,no,lang, andslug.
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 containingpage(page number) andvalue(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)
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
truefor an emptystdClassobject (no properties) — useful when API responses occasionally return empty objects rather than empty arrays. This differs from PHP's nativeempty().
escape
Escapes a string according to the specified type.
Attributes
| Param | Type | Description |
|---|---|---|
| esc_type | String | Escape type: html, htmlall, url, urlpathinfo, quotes, hex, hexentity, decentity, javascript, mail, nonstd (Optional, default 'html') |
| char_set | String | Character 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(htmlspecialcharswithENT_QUOTES),htmlall(htmlentitieswithENT_QUOTES),url(rawurlencode),urlpathinfo(same asurlbut 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]), andnonstd(escape characters with ordinal ≥ 126). nullor 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
| Param | Type | Description |
|---|---|---|
| string | String/Number | The 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
splitmodifier.
function
Calls a custom function.
Attributes
| Param | Type | Description |
|---|---|---|
| var | String | Variable name to store the result (required) |
| id | Integer | ID of the custom function |
| name | String | Identifier 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
| Param | Type | Description |
|---|---|---|
| var | String | Variable name to store the result (required) |
| url | String | URL of the function (required) |
| sa_secret_name | String | Name 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
| Param | Type | Description |
|---|---|---|
| var | String | Variable name to store the result (required) |
| topic | String | Topic name to deliver the message to (required) |
| message | Any | Message to be delivered (required) |
| project | String | GCP project name |
| sa_secret_name | String | Secret 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
| Item | Description | Example |
|---|---|---|
| url | Specify the URL of the page to convert to PDF. | https://www.diverta.co.jp |
| path | Specify 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 |
| option | Specify the options for PDF conversion. | |
| browser_width | Specify the browser width. | browser_width=1280 |
| browser_height | Specify the browser height. | browser_height=2560 |
| sleep | Specify the waiting time (in milliseconds) until the specified page is captured. | sleep=1000 |
| ua | Specify 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" |
| format | Specify the format of the file to be saved. pdf, png, jpeg, jpg, and webp are available. | format="png" |
| cookie | Specify 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 |
| domain | Specify the domain of the cookie. | domain="www.diverta.co.jp" |
| overwrite | Specify whether to overwrite the file if it already exists. | overwrite=1 |
| callback_batch | Specify 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" |
| data | You 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
| Param | Type | Description |
|---|---|---|
| var | String | Variable name to store the result |
| path | String | Path to the file on S3/GCS to retrieve |
| url | String | URL of the file to retrieve |
| bucket | String | Bucket name on S3/GCS where the file to retrieve is located |
| save | Boolean | Whether 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_path | String | File 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
| Param | Type | Description |
|---|---|---|
| result_var | String | true: 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
| Param | Type | Description |
|---|---|---|
| var | String | Variable name to assign data retrieved from Google Analytics |
| updated_topics_ids | Array | An array of content IDs where counter values have been set |
| update_column_slug | String | Slug of the column to update. |
| update_column_index | Integer | Index of the column to update. |
| update_target_metric | String | Metric to use for update. |
| update_target_dimension | String | Custom dimension to update. |
| topics_group_id | Integer | Content definition ID. |
| startDate | String | Start date of the aggregation period. Can be interpreted by PHP's strtotime().Default value is a 7 days before. |
| endDate | String | End date of the aggregation period. Can be interpreted by PHP's strtotime().Default value is today. |
| queries | String | Directly 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.
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
| Param | Type | Description |
|---|---|---|
| file_url | String | The 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) |
| dest | String | The path to save the gzip file. Must be a GCS path (/files/g/). |
| bucket | String | The name of the bucket. If omitted, the storage specified in [External System Integration] - [Firebase] is used. |
| callback_batch | String | The identifier of the batch processing to be called back after the gzip compression is complete. |
| data | Mixed | Any data. Passed to the callback batch. |
Output Variables
| Variable | Description |
|---|---|
| gzip_dest | The 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
| Param | Type | Description |
|---|---|---|
| html | String | HTML content to validate (required) |
| var | String | Variable 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
| Param | Type | Description |
|---|---|---|
| value1 | String or Array | Either the separator string or the array to join (Required) |
| value2 | String or Array | Either 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
| Param | Type | Description |
|---|---|---|
| haystack | Array | The array to search in (Required) |
| strict | Boolean | Use 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
falsesafely whenhaystackis not an array, instead of raising an error. - Loose comparison by default; pass
trueas 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
| Param | Type | Description |
|---|---|---|
| var | String | The variable name to store the result after increment. |
| value | Integer | The value to add (Required) |
| topics_group_id | Integer | Content definition ID (Required) |
| slug | String | Target content's ID/Slug (Required) |
| ext_slug | String | Target column's ID/Slug (Required) |
| index | Integer | sequence 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
| Param | Type | Description |
|---|---|---|
| chars | Integer | Number of indentation characters (Optional, default 4) |
| char | String | Character 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
| Param | Type | Description |
|---|---|---|
| value1 | String or Array | Either the separator string or the array to join (Required) |
| value2 | String or Array | Either 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:
joinsimply delegates toimplode; 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
| Param | Type | Description |
|---|---|---|
| assoc | Boolean | When 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 (
assocdefaults totrue), unlike PHP's nativejson_decode(). - Returns
nullif 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
| Param | Type | Description |
|---|---|---|
| msg1 | String | String 1(within 1KB) |
| msg2 | String | String 2(within 1KB) |
| msg3 | String | String 3(within 1KB) |
| msg4 | String | String 4(within 1KB) |
Example
{logger msg1=$log1 msg2=$log2}
login
Log in.
Attributes
| Param | Type | Description |
|---|---|---|
| member_id | Integer | Member ID |
| overwrite | Boolean | Whether 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
| Param | Type | Description |
|---|---|---|
| var | String | The variable name to store the result (required) |
| cnt | Integer | The number of IDs to be drawn |
| duplicate | Integer | The number of duplicates |
| ids | Array | Target IDs (required) |
| exclude_ids | Array | Excluded 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, usestrtolower(which adds type guards) or PHP'smb_strtolower().
mb_truncate
Truncates a string to the specified length (multibyte-safe).
Attributes
| Param | Type | Description |
|---|---|---|
| length | Integer | Maximum length (Optional, default 80) |
| etc | String | String to append when truncated (Optional, default '...') |
| break_words | Boolean | Break in the middle of words (Optional, default false) |
| middle | Boolean | Truncate 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
etcsuffix length is included in the final output length; whenmiddle=true, the first and last halves are kept and joined byetc. - If the string is already shorter than
length, it is returned unchanged.length=0returns an empty string.
mbtruncate
Truncates a string with multibyte-character support. Internally delegates to the rcms_mbtruncate() function.
Attributes
| Param | Type | Description |
|---|---|---|
| length | Integer | Maximum length of the result (Optional, default 80) |
| etc | String | Suffix 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
| Position | Type | Description |
|---|---|---|
| target | Mixed | The 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
| Position | Type | Description |
|---|---|---|
| target | String | The 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\nbut 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
| Position | Type | Description |
|---|---|---|
| 1 | String | format |
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
| Position | Type | Description |
|---|---|---|
| 1 | String | format |
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
| Param | Type | Description |
|---|---|---|
| property | String | The 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
| Param | Type | Description |
|---|---|---|
| api_endpoint | String | Specify the URL of the endpoint. |
| module | String | Specify the module name. Currently, it supports topics and csvtable and all (required). |
| topics_group_id | int | If the module name is specified as topics, specify the content definition ID. |
| csvtable_id | int | If 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
| Param | Type | Description |
|---|---|---|
| tmp_path | String | The path of the file to upload. Specify a file in the temporary folder. |
| path | String | The destination path of the file. |
| value | String | The content to write to the file. |
| files_path | String | The path on KurocoFiles (/files/(user |
| bucket | String | The 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
| Param | Type | Description |
|---|---|---|
| var | String | Variable name to assign result (optional) |
| action | String | 'encrypt' or 'decrypt' (required) |
| data | String | Data string to encrypt/decrypt (required) |
| key | String | Encryption key (required) - Please use the value of the secret in principle. |
| sanitize | Boolean | Whether 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
| Position | Type | Description |
|---|---|---|
| 1 | Integer | The format type of the result (default=1).
|
| 2 | Integer | The precision of the result in decimals (default=2). |
Example
{$row.path|rcms_file_size}
rcms_hash
Calls the hash function.
Attributes
| Param | Type | Description |
|---|---|---|
| var | String | Name of the variable to store the result (required) |
| algo | String | Algorithm (default=sha256) |
| data | String | Target string (required) |
| key | String | Secret key for HMAC method |
| binary | Boolean | When 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
| Position | Type | Description |
|---|---|---|
| 1 | Array | list |
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
| Param | Type | Description |
|---|---|---|
| var | String | The variable name to store the result (required) |
| pattern | String | The pattern to search for |
| subject | String | The input string |
| flags | Integer | You 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. |
| offset | Integer | The 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
| Param | Type | Description |
|---|---|---|
| var | Array | The variable name to store the result (required). |
| pattern | String | The string representing the pattern to search for. |
| subject | String | The input string. |
| flags | Integer | You 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. |
| offset | Integer | The 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
| Param | Type | Description |
|---|---|---|
| name | String | The name used to identify the read_dir block. |
| file_var | Object | The 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. |
| path | String | The path of the target directory to retrieve. Specify either /files/user or /files/ltd as subdirectories. |
| pattern | String | If you want to filter by file path, specify a regular expression here. |
| recursive | Boolean | When set to true, it will recursively retrieve the contents of subdirectories. |
| name_only | Boolean | When set to true, the file_var variable will return only the file path as a string. |
| type | String | Specify '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
| Param | Type | Description |
|---|---|---|
| name | String | Name to identify the read_file block. |
| path | String | pecify the file path as a relative path from /files/. The accessible directories are as follows:
|
| row | String | Smarty variable to store one line of read data. |
| type | String | File format. Specify 'txt', 'csv', or 'jsonl'. If not specified, the default is 'txt'. |
| ignore_permission | Boolean | If 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
| Param | Type | Description |
|---|---|---|
| add | Array | Array 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
| Position | Type | Description |
|---|---|---|
| 1 | String | This is the regular expression to be replaced. |
| 2 | String | This 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
| Param | Type | Description |
|---|---|---|
| path | String | Path of the directory to remove. |
| status_var | String | Name 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
| Param | Type | Description |
|---|---|---|
| path | String | The path of the file to be deleted |
| bucket | String | The name of the S3/GCS bucket where the file is located |
| status_var | String | The 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
| Param | Type | Description |
|---|---|---|
| src_path | String | Source path |
| dest_path | String | Destination path |
Example
{rename_file src_path=$src_path dest_path=$dest_path}
replace
Simple string search and replace.
Attributes
| Param | Type | Description |
|---|---|---|
| search | String/Array | String(s) to search for (Required) |
| replace | String/Array | Replacement 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. Useregex_replacefor 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
| Param | Type | Description |
|---|---|---|
| value | Mixed | A 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
| Param | Type | Description |
|---|---|---|
| value | String | Content to be saved. |
| var | String | Variable name to store the result. |
Example
{save_file var='path' value=$value}
secret
Retrieves a secret.
Attributes
| Param | Type | Description |
|---|---|---|
| var | String | The variable name to store the result (required) |
| key | String | The 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
| Param | Type | Description |
|---|---|---|
| var | String | The variable name to store the result. If successful, true will be stored; otherwise, false. |
| to | String | The destination email address. You can specify multiple recipients separated by commas. Example: to="test1@example.com, test2@example.com |
| to_member_id | Integer | The destination member id. You can specify multiple recipients separated by commas. Example: to_member_id="1,2" |
| subject | String | The email subject. |
| contents | String | The email body. |
| from | String | The FROM address. |
| from_nm | String | The sender name of the FROM address. |
| cc | String | Email addresses to be specified in CC. If multiple addresses are specified, separate them with commas. |
| cc_member_id | Integer | Member IDs to be specified in CC. If multiple IDs are specified, separate them with commas. |
| bcc | String | Email addresses to be specified in BCC. If multiple addresses are specified, separate them with commas. |
| bcc_member_id | Integer | Member IDs to be specified in BCC. If multiple IDs are specified, separate them with commas. |
| mail_template | String | The identifier of the message template. |
| Variable Name | String | Specifies 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
| Param | Type | Description |
|---|---|---|
| var | String | The 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
| Param | Type | Description |
|---|---|---|
| from_site_key | String | Site key of synchronization source |
| to_site_key | String | Site key of synchronization destination If no specific designation is provided, it will synchronize with your own website. |
| sync_type | Integer | 1: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
| Param | Type | Description |
|---|---|---|
| var | String | The variable name to store the result in. |
| channel | String | The ID of the channel. |
| ts | String | The 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
| Param | Type | Description |
|---|---|---|
| var | String | The name of the variable to store the result. If successful, it will store true, otherwise false. |
| channel | String | The ID of the channel to post the message to. |
| users | Array | An array of user IDs to mention in the message. |
| text | String | The text of the message. |
| thread_ts | String | The 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
| Param | Type | Description |
|---|---|---|
| var | Array | The variable name to store the result. If the process fails, false is stored. |
| team | String | The 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
| Param | Type | Description |
|---|---|---|
| ms | Integer | Time 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
| Param | Type | Description |
|---|---|---|
| spacify_char | String | String 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
| Param | Type | Description |
|---|---|---|
| string | String/Number | The 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
| Param | Type | Description |
|---|---|---|
| var | String | Name of the variable to store the result. |
| path | String | Path of the file on S3/GCS. |
| expire | String | Expiration 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
| Param | Type | Description |
|---|---|---|
| format | String | sprintf 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
| Param | Type | Description |
|---|---|---|
| replace_with_space | Boolean | Replace 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>becomesHello World, notHelloWorld). - When
replace_with_space=false, PHP'sstrip_tags()is used, which completely removes the tags. Content between tags is preserved either way.
strtodate
Get date from timestamp.
Attributes
| Param | Type | Description |
|---|---|---|
| var | String | Variable name to store the result (required) |
| timestamp | Int|String | Timestamp |
| format | String | Format |
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 tolower, 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 toupper, but with explicit non-scalar handling.
substr
Returns a substring from the input string, with type checking.
Attributes
| Param | Type | Description |
|---|---|---|
| start | Integer | Start position (0-based; can be negative) (Required) |
| length | Integer | Length 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
startcounts from the end of the string; a negativelengthomits that many characters from the end. - NOT multibyte-safe — counts bytes, not characters.
subtract
Subtracts a number from a variable.
Attributes
| Param | Type | Description |
|---|---|---|
| var | String | The variable name to store the result (required) |
| value | Int | The 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
| Param | Type | Description |
|---|---|---|
| ids | Array/String | Array 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
| Position | Type | Description |
|---|---|---|
| target | Array | The 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
| Position | Type | Description |
|---|---|---|
| target | Array | The array to be converted (required). |
Example
{assign var='foo' value=$bar|@to_object}
truncate
Truncates a string to the specified length (byte-based).
Attributes
| Param | Type | Description |
|---|---|---|
| length | Integer | Maximum length (Optional, default 80) |
| etc | String | String to append when truncated (Optional, default '...') |
| break_words | Boolean | Break in the middle of words (Optional, default false) |
| middle | Boolean | Truncate 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/substrand is NOT multibyte-safe — for UTF-8 or other multibyte encodings, usemb_truncateinstead. - When
break_words=false(default), truncation occurs at the nearest word boundary; whenmiddle=true, the first and last halves are kept and joined byetc.
twitter_post_message
Sends a message to Twitter.
Attributes
| Position | Type | Description |
|---|---|---|
| var | String | The variable name to store the result. |
| text | String | The 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.
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
| Param | Type | Description |
|---|---|---|
| src | String | The 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/...). |
| dest | String | The 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. |
| bucket | String | The name of the bucket. If omitted, the storage specified in [External System Integration] - [Firebase] is used. |
| callback_batch | String | The name of the batch processing to be called back after the zip extraction is complete. |
| data | Mixed | Any data. Passed to the callback batch. |
| overwrite | Integer | Whether to overwrite the file with the same name in the destination folder if it already exists. 0 or 1. |
| detect_order | Array | You 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
| Param | Type | Description |
|---|---|---|
| var | String | The variable name to store the result. |
| value | Integer | The value you want to set (Required) |
| topics_group_id | Integer | Content definition ID (Required) |
| slug | String | Target content's ID/Slug (Required) |
| ext_slug | String | Target column's ID/Slug (Required) |
| index | Integer | sequence 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, usestrtoupper(which adds type guards) or PHP'smb_strtoupper().
usage_price_format
Formats a usage/price value for display using the RCMS_Usage formatting system.
Attributes
| Param | Type | Description |
|---|---|---|
| edge_flg | Boolean | Edge 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
| Param | Type | Description |
|---|---|---|
| var | String | Variable to store. |
Example
{uuid var='foo'}
wordwrap
Wraps text to a specified line length.
Attributes
| Param | Type | Description |
|---|---|---|
| length | Integer | Line width in characters (Optional, default 80) |
| break | String | String inserted as a line break (Optional, default "\n") |
| cut | Boolean | Force-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; withcut=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
| Position | Type | Description |
|---|---|---|
| path | String | The file path. If omitted, the file is automatically written to a temporary area with a unique file name. |
| var | String | The variable name to store the temporary file path that was written (required). |
| value | String | Array | The data to be written. If an array is specified, it will be written in CSV format. |
| is_append | Integer | Append 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
| Param | Type | Description |
|---|---|---|
| var | String | The variable name to store the result. (required) |
| xml | String | The XML to be converted. |
| convert_namespace | Integer | When 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.
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
| Position | Type | Description |
|---|---|---|
| entries | Array | List 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/...). |
| dest | String | The 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. |
| bucket | String | Bucket name. If omitted, the Storage set up in [External System Integration] - [Firebase] will be used. |
| callback_batch | String | Batch processing name to be called back after the Zip compression process is completed. |
| data | Mixed | Any 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.