Custom Module Classes

Charles Matvchuk asked on March 27, 2017 19:08

Looking for some ideas.

I have a Car Custom Module that has a multitude of classes in it which have referential integrity. The main entity is "Car" which contains 70 fields which all apply to the "Car" itself. The additional classes are all 1 to many (associated to car) and there are 14 of them.

Typically when I build a system I would create a custom page type "Car", with all 70 fields and go from there, as well as you Global Events to clean up the child tables since I do not link any child tables to custom page types, which is also best practice.

My thought is to create a custom page type "Car" with a CarID Field, A Car Name and then bind the custom "Car" class to the page via query etc. Unfortunately I lose a lot of the document binding in such a scenario, but if the page is deleted I do not lose the "Car". Finally I can handle all of referential integrity, etc., in code in the custom module classes.

Any thoughts? Is there a better way?

Recent Answers


Brenden Kehren answered on March 27, 2017 22:02

Couple questions,

  • Do you need the node data or a place in the content tree?
  • Do you need to have those 70 different attributes and 14 different 1:N classes in the content tree?
  • Do any of those 70 different attributes and 14 different 1:N classes need to be searchable?

I can think of a good way to do this with page types and I can think of a way to do this with a custom module. But if you really need to have the node data behind it, you're better off with custom page types and setting the scopes and parent/child relationships.

If you have some custom code needing to be placed behind the classes, then probably better to use the custom module/classes so you can incorporate it all together.

0 votesVote for this answer Mark as a Correct answer

Charles Matvchuk answered on March 27, 2017 23:09

Brenden,

The car needs node data and a place in the content tree, with SEO features and such. The 14 different classes do not need to be in the content tree. The attributes are searchable but not with site search, the are in a custom grid I have built.

I was going down the same path you suggested, thinking it may just be best to do a hybrid with Global Events for cleanup?

Thoughts?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on March 27, 2017 23:13

I like the idea of the global events as long as you're comfortable you're deleting all the respective items/records.

So your custom "Car" page type could still have those other fields or attributes related to it on the Form tab. You could create some custom form controls to write data to those other tables (custom tables, module classes, etc.) Just depends on what you want to do I guess. It would be very similar to how you can add categories or attachments. Just don't make those items available until after they have the main node created.

0 votesVote for this answer Mark as a Correct answer

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