Note that there are some explanatory texts on larger screens.

plurals
  1. POContentHandler issues (circular reference) in Orchard
    text
    copied!<p>crosspost: <a href="https://orchard.codeplex.com/discussions/459007" rel="nofollow">https://orchard.codeplex.com/discussions/459007</a></p> <p>First question I have is what would be the repercussions of having 2 PartHandlers for the same Part in 2 different modules? </p> <p>I got into this predicament because I have to run a method once a specific Content Type is created. It would be as easy to hook onto OnCreated for the part, however, here is my scenario: </p> <ul> <li>Module A contains the part and the original handler</li> <li>Module B contains the service where the method is</li> <li>Module B has a reference to Module A</li> </ul> <p>Therefore, I am unable to reference Module B within Module A (circular reference). So what I did was to copy the exact same PartHandler in Module A and placed it in Module B. </p> <p>Would anything be wrong with that? </p> <p>Then comes my second question, which I think could solve all these problems: Can we create a PartHandler for the Content Item's default Content Part? (i.e. the part where all custom fields are attached to) </p> <p>This would definately make things easier as I could consolidate stuff that need to run there.</p> <p><strong>UPDATE 1 (to better explain question 2)</strong></p> <pre><code> ContentDefinitionManager.AlterPartDefinition("EventItem", builder =&gt; builder .WithField("StartDate", cfg =&gt; cfg .OfType("DateTimeField") .WithDisplayName("Start Date") .WithSetting("DateTimeFieldSettings.Display", "DateOnly") .WithSetting("DateTimeFieldSettings.Required", "true")) .WithField("StartTime", cfg =&gt; cfg .OfType("DateTimeField") .WithDisplayName("Start Time") .WithSetting("DateTimeFieldSettings.Display", "TimeOnly")) .WithField("EndDate", cfg =&gt; cfg .OfType("DateTimeField") .WithDisplayName("End Date") .WithSetting("DateTimeFieldSettings.Display", "DateOnly")) .WithField("EndTime", cfg =&gt; cfg .OfType("DateTimeField") .WithDisplayName("End Time") .WithSetting("DateTimeFieldSettings.Display", "TimeOnly")) .WithField("Intro", cfg =&gt; cfg .OfType("TextField") .WithDisplayName("Intro") .WithSetting("TextFieldSettings.Flavor", "textarea")) ContentDefinitionManager.AlterTypeDefinition( "EventItem" , cfg =&gt; cfg .DisplayedAs("Event Item") .WithPart("TitlePart") .WithPart("EventItem") .WithPart("LocationPart") .WithPart("AutoroutePart", builder =&gt; builder .WithSetting("AutorouteSettings.AllowCustomPattern", "true") .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false") .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: 'learn/events/{Content.Slug}', Description: 'learn/events/event-title'}]") .WithSetting("AutorouteSettings.DefaultPatternIndex", "0")) .WithPart("CommonPart") .Draftable() .Creatable() ); </code></pre> <p>I'm talking about creating a ContentHandler for the EventItem part which holds all the custom fields. How can I go about it when EventItemPart is not defined in any class in the solution?</p> <p>The following below won't work since it can't find the class EventItemPart:</p> <pre><code>OnCreated&lt;EventItemPart&gt;((context, keynotes) =&gt; questionService.SetDefaultQuestions(context.ContentItem)); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload