@iter

Iterate over the keys of an object. Useful when looking for a particular json key.

Makes the following available to the context of each iteration: $key
$value
$type

Syntax

   {@iter obj=<object>/}

Parameters

  • obj - (required) the object whose keys will be iterated over (example: "content.attachments")

Example

This example looks for a node attachment by name. The name is specified in another node property 'attachmentId'

{@queryOne type="myPageType:navigation" }
{@content id="{_doc}"}
<nav id="nav">
    <ul id="navigation">
        {#links}
            {?isAttachmentLink}
                {@iter obj=content.attachments}
                {@if cond="\"{$value._doc}\" == \"{attachmentId}\""}
                    <li><a {?linkTarget}target="{linkTarget}"{/linkTarget} href="{$value.url}">{linkTitle}</a></li>
                {/if}
                {/iter}
            {:else}
                <li><a {?linkTarget}target="{linkTarget}"{/linkTarget} href="{linkURL}">{linkTitle}</a></li>
            {/isAttachmentLink}
        {/links}
    </ul>
</nav>
{/content}
{/queryOne}