Skip to content

Commit 32046ed

Browse files
authored
Merge pull request #1017 from nep/patch-22
Update relationships.md
2 parents b169812 + 3da5fbe commit 32046ed

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/fieldtypes/relationships.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,17 @@ You would access the child entry in your template using the following syntax:
180180
{relationship_field:field2}
181181
{/exp:channel:entries}
182182

183-
No looping occurs.
183+
No looping occurs. (If you use this syntax when the field does have multiple child relationships, this will display the content from first item only.)
184+
185+
### Usage: Testing for Child Entries with a Conditional
186+
187+
There are two ways to test if there are any children belonging to the current entry and display content if there are none.
188+
189+
Outside of the `{relationship_field}` loop, use `{relationship_field:count}`, which will be either "" or "1". (Inside the loop, `{relationship_field:count}` always displays the current count.) You can also consider `{relationship_field:total_results}`, which will display the total count of children.
190+
191+
Therefore, the conditional to test for no child entries is: `{if "{relationship_field:count}" == ""}...{/if}`
192+
193+
Inside the `{relationship_field}` loop, you can use an `{if relationship_field:no_results}...{/if}` conditional.
184194

185195
## Accessing Siblings
186196

0 commit comments

Comments
 (0)