Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello all, I'm relatively new to Umbraco and after going through all of the tutorials I managed to get my hands on, I still couldn't find an answer to my question -
Is it possible in Umbraco to define a "constructor" for a document type,
Regardless of its hierarchical position as a page of itself, or as a nested content in another document type.
The idea I'm pursuing is to define a custom code section to initialize things that are external to Umbraco, to allow my content editors to use this document type on any other document type (as a child) and for the custom code for my first document type (the nested one) to be initialized accordingly.
I'm aware of route hijacking and I am currently using it, but with that approach I'm bound to define a custom controller per each new document type that is intended to use my nested document type, i'm wondering if there is a way to achieve what I'm after.. (sort of a constructor\event handler for the child document type)
Thanks in advance to all potential helpers :)
Also you can use ContentService events - https://our.umbraco.org/documentation/reference/events/contentservice-events
Split code for each document type and call some constructor per document type if it's the case.
Hey Alex, thanks for replying.
The thing is that there are no "on load" event for documents, only published and created.
I wish to run a custom code for each document type, regardless of said document type being a page on its own or as children of another document type...
it seems that this is impossible, thus i cannot completely encapsulate a document type's custom logic inside it.
I must take into account WHERE is that document being used (and deal with the custom logic of it in that place i.e. a parent document..)
Am I correct or am i missing something?
Write your reply to:
Image will be uploaded when post is submitted