How to Create a one_to_many Relationship
Guide in creating a one_to_many relationship field in Zesty.io
A good way to explain one-to-many relationships is through tags. In Zesty.io blogs, tags can be used to tie related content together.
To demonstrate how to use tags, lets make a blog content model. Once the blog is created, create a new Article Tag from the content page.
Now in the Articles section, you can select a tag from the 'Article Tags' field.
The one-to-many relationship here works in that you can have many tags to one article. This is particular useful for organizing your content, or even doing creative things like looping through the tags to create a way to filter through articles by the tags themselves. For a guide to do just that, click here
In Parsley
When you create a blog in zesty, the logic behind the tags is already set up. Lets take a look at how tags are connected to articles in Parsley:
{{if {thispage.tags} > 0 }}
<div class="tags">
<strong>Tagged:</strong>
{{each blog_tag as tag
where FIND_IN_SET(tag.zid,'{thispage.tags}') }}
<a href="{{tag.getUrl()}}" itemprop="keywords" rel="tag">{{tag.name}}</a>
{{end-each}}
</div>
{{end-if}}
The above code creates the listing of tags in the article 'tag' page:
Updated 9 months ago