Related Documents through a Repeater

1/14/2016 12:00:00 AM

Sooner or later you will come across this situation where you need to show related documents to a document. Secondly, there could be more than one related document to a document however finding a logical link between these documents would be a challenge. To make it more difficult your customer would like to have a control of this "is-related" relationship.

Difficult? Not at all. With Kentico Repeaters, Transformations and Relationships featrure among documents this will be a cake walk. However, I took me a day recently when I was in need of this solution.

Suppose you want to show related blog to a blog and there is no clear cut relationship between them. This is how you can show related blogs using a repeater a existing transformation.




After clicking here you will see a screen like this.



Left handside document is the document to which you want to add new releated documents. Click on  "Select Page" to add the related document. Notice the relationship between them is "is related to". You can create any number of relationships in Kentico and select the right relationship during the time of the selection.

You can add any number of documents as related document to the original document.

This will create a relationship entry like this.



After this you are ready to use this inside a repeater to display related documents. Add a Repeater to your template and fill the basic details. Keep path as empty to show releated document to this dcument only.  Fill the value of "Show for Page types" as the one on which you would like to show related blogs.

After filling this come to the Relationship section of the blog. Most Important.

See appropriate values as in the screenshot below and you are done. 



Golden Tip:- This technique will give your content editors to create and destroy relationships on the fly without ever coming back to developers.

I hope this small tip will be useful for your projects.