Keywords Field Type
The keywords field type allows you to enter keywords or tags for your entries.
Parameters
Parameter | Default | Description |
---|---|---|
return_type | string | Allows you to return the keywords as a string or array. See formats below. |
Output
Depending on your Return Type, you will have different outputs. Your two possible outputs are a string or an array.
A string output will comma separate each keyword. You will only need to call your keywords with a single var tag like normal. Here is the example format for a string:
# Keywords: keyword_1, keyword_2, keyword_3
// template
{{ keywords }}
// output
keyword_1, keyword_2, keyword_3
Returning your keywords as an array allows for more flexibility to customize the output. Arrays will be printed out with open and closing tags like so:
# Keywords: keyword_1, keyword_2, keyword_3
// template
{{ keywords }}
{{ keyword }}{{ if !is_last }}, {{ endif }}
{{ /keywords }}
// output
You can see how much more customized this output is. This allows you do almost what ever you please. In addition to the keyword
and is_last
vars you have in the example above, you also have a few others. This is what gets returned with each keyword:
keyword, count, total, is_first, is_last
Here is one more quick example of how to create a keyword list with total keywords:
# Keywords: Shopping, Electronics, Technology
// template
{{ keywords }}
{{ if is_first }}
{{ total }} Keywords
{{ endif }}
- {{ keyword }}
{{ if is_last }}
{{ endif }}
{{ /keywords }}
// output
3 Keywords