Custom Module Class to CMS_Node Relationship - Kosher?

Senior Software Engineer - Kentico Xperience MVP

Trevor Fayas asked on February 14, 2017 23:28

I want to get some other developer/support opinions. I have a case where I have "Products" in the Pages Tree, that i want to assign a many to one relationship with a custom class object (ex. a Product has multiple Accessories, which Accessories i'm making a custom class).

The documentation warns that you shouldn't link Custom Module objects to Pages because of the advanced structure of Pages. However in my case, i neither care about versioning, workflows, nor cultures (even though all of these exist).

Anyone foresee any harm in referencing the NodeID to these Accessories, as the CMS_Tree is not versioned, cultured, etc. I know full well that doing this will mean any relationship will exist instantly and will operate separate from the page's version/workflow/cultures.

Correct Answer

Roman Hutnyk answered on February 15, 2017 08:09

Trevor, recently I worked with the similar problem. I don't see it to be an issue. The only thing you might need to handle is deleting Accessories when someone deletes a page.

Also I've implemented extra tab for a page, that lists assigned "Accessories", but couldn't find any better way to retrieve NodeID than getting it from URL with appropriate macro. I'd love to hear if there is better way to get it.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Dawid Jachnik answered on February 15, 2017 14:27

Hello, not exacly, you can pass there NodeGUID which is better than NodeID.

You can achive that my overriding the default extender ContentEditTabsControlExtender located in /App_Code/CMSModules/Content/Extenders/ContentEditTabsControlExtender.cs which is assigned as tab exntender in Edit ui element of Pages. You need to change one line of method OnTabCreated: search for

tab.RedirectUrl = DocumentUIHelper.GetDocumentPageUrl(settings);

and replace it with

tab.RedirectUrl = URLHelper.AddParameterToUrl(DocumentUIHelper.GetDocumentPageUrl(settings), "nodeguid", Node.NodeGUID.ToString());

It's not good to modify system files, but... you know ;)

2 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on February 15, 2017 15:12

Thanks for the validation, and fun little trick Dawid (although i also try not to modify any system files, it's nifty to know how to do it if i want to, nice job!)

I can only mark 1 answered, so i'll hit Romans but i'll upvote yours Dawid.

NodeID should be fine vs. GUID though as long as you set up your custom module to properly reference the Node ID, that way when it is pushed int staging it translate properly (goal is to optimize the SQL through ID only lookups).

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.