Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/designers/language-modifiers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ These parameters follow the modifier name and are separated by a `:`

- [capitalize](language-modifier-capitalize.md)
- [cat](language-modifier-cat.md)
- [count](language-modifier-count.md)
- [count_characters](language-modifier-count-characters.md)
- [count_paragraphs](language-modifier-count-paragraphs.md)
- [count_sentences](language-modifier-count-sentences.md)
- [count_words](language-modifier-count-words.md)
- [debug_print_var](language-modifier-debug-print-var.md)
- [date_format](language-modifier-date-format.md)
- [default](language-modifier-default.md)
- [escape](language-modifier-escape.md)
Expand Down
21 changes: 21 additions & 0 deletions docs/designers/language-modifiers/language-modifier-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# count

Returns the number of elements in an array (or Countable object). Will return 0 for null.
Returns 1 for any other type (such as a string).

If the optional mode parameter is set to 1, count() will recursively count the array.
This is particularly useful for counting all the elements of a multidimensional array.

## Basic usage
```smarty
{if $myVar|count > 3}4 or more{/if}
{if count($myVar) > 3}4 or more{/if}
```


## Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|--------------------------------------------------------|
| 1 | int | No | If set to 1, count() will recursively count the array. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# debug_print_var



Returns the value of the given variable in a human-readable format in HTML.
Used in the [debug console](../chapter-debugging-console.md), but you can also use it in your template
while developing to see what is going on under the hood.

> **Note**
>
> Use for debugging only! Since you may accidentally reveal sensitive information or introduce vulnerabilities such as XSS using this
method never use it in production.

## Basic usage
```smarty
{$myVar|debug_print_var}
```


## Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|------------------------------------------------------------------------|
| 1 | int | No | maximum recursion depth if $var is an array or object (defaults to 10) |
| 2 | int | No | maximum string length if $var is a string (defaults to 40) |

4 changes: 3 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ nav:
- 'Introduction': 'designers/language-modifiers/index.md'
- 'capitalize': 'designers/language-modifiers/language-modifier-capitalize.md'
- 'cat': 'designers/language-modifiers/language-modifier-cat.md'
- 'count': 'designers/language-modifiers/language-modifier-count.md'
- 'count_characters': 'designers/language-modifiers/language-modifier-count-characters.md'
- 'count_paragraphs': 'designers/language-modifiers/language-modifier-count-paragraphs.md'
- 'count_sentences': 'designers/language-modifiers/language-modifier-count-sentences.md'
- 'count_words': 'designers/language-modifiers/language-modifier-count-words.md'
- 'debug_print_var': 'designers/language-modifiers/language-modifier-debug-print-var.md'
- 'date_format': 'designers/language-modifiers/language-modifier-date-format.md'
- 'default': 'designers/language-modifiers/language-modifier-default.md'
- 'escape': 'designers/language-modifiers/language-modifier-escape.md'
Expand Down Expand Up @@ -122,4 +124,4 @@ nav:
- 'programmers/caching.md'
- 'programmers/resources.md'
- 'programmers/advanced-features.md'
- 'programmers/plugins.md'
- 'programmers/plugins.md'