Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

How to avoid circular reference in a content area when using the content delivery api?



We implemented this part of an optimizely article to expand multiple levels of nested ContentArea property. We plan on making this our default way to fetch data from the content delivery api:

Now we found an issue with this approach when there is a circular reference in the hierarchy of the fetched data. Where for example:                                      

'A ' contains a content area, inside of it is a content called 'B' that references back to 'A' in it's own content area as well.

From this we get a circular reference which would crash the application.

Any suggestion to help detect a circular reference when it happens to solve this issue?

Thanks in advance.

May 06, 2024 12:39

Hi Taher,

First of all, I think we should make Allow Types tightly to restrict allowed types in content area first to avoid circurlar reference as much as possible. After that, you can add customized validation to check if there is any circular reference once saving content.

You can use GetReferencesToContent method from IContentRepository for circular reference validation.

Edited, May 07, 2024 3:19
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.