Note that there are some explanatory texts on larger screens.

plurals
  1. POOrchard CMS: Connect List content part to content item
    primarykey
    data
    text
    <p>I have been struggling with what I thought would be simple.</p> <p>I have a content type called Supplier. This supplier has contact information containing two addresses, one for Correspondence Address and one for Visiting Address. The supplier has also several locations, like location north and location south. A location is also an address. So basically I have a content item Supplier with a lot of addresses and all of them with their own type.</p> <p>Migration:</p> <pre><code> public int Create() { //Creating the Location contentrecord, contentpart and contenttype SchemaBuilder.CreateTable("LocationPartRecord", table =&gt; table .ContentPartRecord() .Column&lt;int&gt;("LocationsPartRecord_id") ); ContentDefinitionManager.AlterPartDefinition("LocationPart", part =&gt; part .Attachable(false) .WithField("LocationName", f =&gt; f.OfType("TextField")) .WithField("AddressLine1", f =&gt; f.OfType("TextField")) .WithField("AddressLine2", f =&gt; f.OfType("TextField")) .WithField("Zipcode", f =&gt; f.OfType("TextField")) .WithField("City", f =&gt; f.OfType("TextField")) .WithField("Country", f =&gt; f.OfType("TextField"))); ContentDefinitionManager.AlterTypeDefinition("Location", cfg =&gt; cfg .WithPart("CommonPart") .WithPart("LocationPart") ); //Creating the Locations 'container' contentpart SchemaBuilder.CreateTable("LocationsPartRecord", table =&gt; table .ContentPartRecord() ); ContentDefinitionManager.AlterPartDefinition("LocationsPart", builder =&gt; builder.Attachable()); //Creating the supplier. Specific supplier contentfields can be added later. Doing records, so I can add //datafields later that are not contentfields SchemaBuilder.CreateTable("SupplierPartRecord", table =&gt; table .ContentPartRecord()); ContentDefinitionManager.AlterPartDefinition("SupplierPart", part =&gt; part .Attachable(false) ); ContentDefinitionManager.AlterTypeDefinition("Supplier", builder =&gt; builder .Creatable() .Draftable() .WithPart("CommonPart") .WithPart("TitlePart") .WithPart("BodyPart") .WithPart("AutoroutePart", partBuilder =&gt; partBuilder.WithSetting("AutorouteSettings.AllowCustomPattern", "true") .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Supplier', Pattern: 'aanbieders/{Content.Slug}', Description: 'aanbieders/supplier-name'}]") .WithSetting("AutorouteSettings.DefaultPatternIndex", "0")) .WithPart("SupplierPart") .WithPart("LocationsPart")); return 1; } </code></pre> <p>Models: *<em>LocationPartRecord and LocationPart *</em></p> <pre><code>public class LocationPartRecord:ContentPartRecord { public virtual LocationsPartRecord LocationsPartRecord { get; set; } } public class LocationPart:ContentPart&lt;LocationPartRecord&gt; { LocationsPartRecord LocationsPartRecord { get { return Record.LocationsPartRecord; } set { Record.LocationsPartRecord = value; } } } </code></pre> <p><strong>LocationsPartRecord and LocationsPart (container)</strong> public class LocationsPartRecord:ContentPartRecord {</p> <pre><code> public LocationsPartRecord() { Locations = new List&lt;LocationPartRecord&gt;(); } [CascadeAllDeleteOrphan] public virtual IList&lt;LocationPartRecord&gt; Locations { get; set; } } public class LocationsPart:ContentPart&lt;LocationsPartRecord&gt; { public LocationsPart() { Locations = new List&lt;LocationPart&gt;(); } public readonly LazyField&lt;IList&lt;LocationPart&gt;&gt; _locations = new LazyField&lt;IList&lt;LocationPart&gt;&gt;(); public IList&lt;LocationPart&gt; Locations { get { return _locations.Value; } set { _locations.Value = value; } } } </code></pre> <p>From here I am stuck. I would like to see when Creating a new supplier, I get a screen containing all the content item fields for supplier and a list of locations, with the ability to create, delete or update a location.</p> <p>I don't need the code to be spelled out, but a direction would suffice. Which drivers, controllers and views should I create. This is only for admin console. For frontend the locations need to be displayed and not edited.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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