开发者

Sitecore : how to avoid breaking dependencies of items that are referenced via Control-Datasource

Using Sitecore.NET 6.3.0.

Our Sitecore content has a great deal of items that refer to other items via the control renderings collection. This is done by setting a path to the item as the controls' datasource.

Since this link is specified via a path - not an id - to the linked item, it is currently possible to break the link if you change the linked item's location, or delete it completely.

With the goal of either preventing broken links, or at least detecting them before a publish, what is the best approach to avoiding this problem?

I'm aware that it is possible to link in a standard way (reference by id), but this would rule out any links where we must link via relative paths.

Is there any way to go about detecting, or even better preventing broken links of this kind?

EDIT: This is more akin to assigning a DataSource to a su开发者_运维技巧blayout in presentation layout details, rather than doing anything in code. (Its something a content editor would do).


I'm not sure what the best approach is, but I do agree there's potential for a lot of problems here.

While reading your post, I was thinking... albeit a naughty move, but you COULD change the field type of the "DataSource" field. Of course, mucking about in system templates is something to be cautionable about - but in this case, the alternative seems slightly worse.

If doing so, you would need to hook into the getRenderingDatasource pipeline as well, and override the GetDatasourceLocation step.

I've not done this myself, so cannot guarantee it will work. Seems fairly straight forward however :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜