Create new module for databse entry

Topics: Customizing Orchard, Writing modules
Jul 2, 2011 at 12:01 PM

Hi,

I have created module to collect user data. I have follow all the step in orchard document. 

When i goto content ->content Types menu 

i can see this

When i click create new its comming data entry form with  Title, Body and tag. But i created edittemplate with  Types, SubTypes and Name

I want enter Those data.

Why this happen?

 

And how can i put list of user data to my home page?

 

krds

lakmal

Coordinator
Jul 3, 2011 at 12:37 AM

You probably forgot to add placement.info for your new part.

Jul 3, 2011 at 1:16 PM

Hi,

 

Here is my palcement.info  content

 

<Placement>
    <Place Parts_Exide="Content:10"/> 
<Place Parts_Exide_Edit="Content:7.5"/>

</Placement>

Is this wrong? Whats correctentry

 

lakmal

Coordinator
Jul 3, 2011 at 9:30 PM

That looks correct. Next thing to check would probably be to check that the name of the shape as created from the driver really is Parts_Exide_Edit.

Jul 4, 2011 at 7:46 AM

This is my driver

 

namespace Exide.Drivers
{
    public class ExideDriver : ContentPartDriver
    {
        protected override DriverResult Display(
            ExidePart part, string displayType, dynamic shapeHelper)
        {
            return ContentShape("Parts_Exide",
                () => shapeHelper.Parts_Exide(
                    Type: part.type,
                    Secondary_type: part.Secondary_type,
                    Name: part.Name ,
                    Address: part.Address,
                    Address_Line: part.Address_Line ,
                    City: part.City ,
                    State: part.State,
                    Country: part.Country ,
                    ContentItem: part.ContentItem,
                    Displayaddresse: part.Displayaddress ,
                    Fax: part.Fax,
                    Fields: part.Fields,
                    Image: part.Image,
                    Lat: part.Lat,
                    Lin: part.Lin  ,
                    PartDefinition: part.PartDefinition,
                    Phone: part.Phone,
                    published: part.published,
                    Tollfree: part.Tollfree                     
                    ));
        }

        //GET
        protected override DriverResult Editor(ExidePart part, dynamic shapeHelper)
        {
            return ContentShape("Parts_Exide_Edit",
                () => shapeHelper.EditorTemplate(
                    TemplateName: "Parts/Exide",
                    Model: part,
                    Prefix: Prefix));
        }

        //POST
        protected override DriverResult Editor(
            ExidePart part, IUpdateModel updater, dynamic shapeHelper)
        {
            updater.TryUpdateModel(part, Prefix, null, null);
            return Editor(part, shapeHelper);
        }
    }
}

Coordinator
Jul 4, 2011 at 7:50 AM

This all looks fine. Are you sure you added the part to the type?

Jul 4, 2011 at 7:53 AM

Hi,

 

Whats type, Can i have some explanation

 

Coordinator
Jul 4, 2011 at 8:01 AM

You must have created a content type, if you have something new under the "New" menu header.

Jul 4, 2011 at 10:07 AM

Hi,

I went to Content->Content Type->Click Edit in Exide

 

and add part->tick Exidepart

 

But still i cant see Exide properties

Under new menu i can see Exide. When i click it its comming only with Title and body properties, not exide peroperty there

This is my router file

 

 public class Routes : IRouteProvider
    {
        public void GetRoutes(ICollection routes)
        {
            foreach (var routeDescriptor in GetRoutes())
                routes.Add(routeDescriptor);
        }

        public IEnumerable GetRoutes()
        {
            return new[] {
                new RouteDescriptor {
                    Priority = 5,
                    Route = new Route(
                        "Exide",
                        new RouteValueDictionary {
                            {"area", "Exide"},
                            {"controller", "Home"},
                            {"action", "Index"}
                        },
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "Exide"}
                        },
                        new MvcRouteHandler())
                }
            };
        }
    }
}

and here is my views->Editortemplate->parts-Exide.cshtml  code

 

@model Exide.Models.ExidePart
<fieldset>
    <label class="sub" for="type">@T("Type")</label>
@Html.TextBoxFor(m => m.type , new { @class = "text" })
<label class="sub" for="Type">@T("Secondary_type")</label>
@Html.TextBoxFor(m => m.Secondary_type , new { @class = "text" })
<label class="sub" for="Name">@T("Name")</label>
@Html.TextBoxFor(m => m.Name, new { @class = "text" }) </fieldset>

Coordinator
Jul 5, 2011 at 10:53 PM

What do you need the route for?