Content Type Field Name

Topics: Francais (French)
Jan 12, 2013 at 3:19 PM
Edited Jan 12, 2013 at 3:20 PM

I want to hide/remove my some of content type field Display Name that I added manually, I need the field display name only on admin site.

For example: I have Content Type Field as "Duration" and when data is added by admin it value is 3 Days then I want to display only 3 Days on my site.

I am very new for orchard 1.6 so please help me out,

Thanks

Developer
Jan 12, 2013 at 3:29 PM

You can override shape templates (a content field has a driver that generates shapes, which are rendered using Razor templates). These template overrides need to be stored as part of your theme. To find out which shapes you can override, enable the Shape Tracing feature. It also provides a "Create" button next to each shape and shape alternate to create the template for you, which you can then completely customize.

Jan 15, 2013 at 5:48 AM

thanks for you post,

I can override the view page and it's working for me, i have keep file name as View\Fields\Common.Text.cshtml but it shows only Fields. i have content banner parts and i want to override it while rendering because it contain only image but i want to have URL on the image, i have URL on Field.

My objective is to show image on home page having link to another content/ page or whatever.

I am also made custome content type but it need lots of coding.

The basic need is i am planning to migrate my site http://www.arihantholidays.com/ into orchard because it's very difficult to manage content on my site, please advice me what is the best way to migrate.

 

Thanks,

Suraj

Developer
Jan 15, 2013 at 8:53 AM

I'm not sure what your question is about template overriding. Do you have a custom content type with fields where you want to customize the rendering of that content type and render its fields in that template? If you could elaborate we may be better able to help.

The way I would migrate your site is by start creating a custom theme and module, create the various content types, parts and fields and implement templates for them. Once that's all wired up and the site works with dummy data, it's a matter of importing data from the live site into Orchard. Except for the data that's not part of the live site, i.e. when you're querying external data sources.

If you have more specific questions, please do let us know.

Jan 15, 2013 at 10:31 AM

Thanks for your reply,

I am little bit confusion to migrate my site to Orchard 1.6,

I build my module name as "HolidaysPackages" which consists of Package Duration, Package Rate , Package Thumnell image, Package Itinerary, Package Details,Package Term and Conditions and etc, but i want to show my Holidays Package module on list view with minimum information, i have receltely added on List View and render on Content zone of orchard everything is works good but how can i show only few info like Package Duration, Package Rate and Package Image  on List View? currently all fields is render on list view and it mess up everything. I am also trying to figure out but it's taking too much time.if possible share me same sample code.

 

Suraj

Developer
Jan 15, 2013 at 12:35 PM

I see. So you are rendering a list of HolidayPackage content items. This list is typically rendered using the "Summary" display type, so what you could do is add a

<Match ContentType="HolidayPackage">
   <Match DisplayType="Summary">
      <Place Fields_MediaPicker-Thumbnail="-" /> <!-- This is an example, you have to use real shape names here. The "-" indicates that the shape should not be rendered -->
   </Match>
</Match>

to Placement.info of your theme or module.

Inside of that match element, add <Place /> elements to specify where and if a field shape should be rendered.
(I'm assuming you're working with content fields)

Alternatively, you can override the entire content shape of the HolidayPackage type for the Summary display mode:

Content-HolidayPackage.Summary.cshtml.

In there, you can access all the parts and fields of the content item.

As a final note, you may want to consider using Projections over Lists, since Lists are deprecated and Projections can do the same, but have more flexibility, options and power, should you need it.

Jan 17, 2013 at 10:24 AM

Thanks your reply,

why i can not save the data on database, previous code that i downloaded is working very good (download from your article), but my value is not saving on database.

Model

using Orchard.ContentManagement.Records;

namespace Holidays.Package.Models
{
    public class HolidaysPackagePartRecord : ContentPartRecord
    {
        public virtual decimal Price { get; set; }
        public virtual string Duration { get; set; }
        public virtual string currencyCode { get; set; }
        public virtual string thumnellImageLink { get; set; }
        public virtual string packageDetailsLink { get; set; }
    }
}

using Orchard.ContentManagement;

namespace Holidays.Package.Models
{
    public class HolidaysPackagePart : ContentPart<HolidaysPackagePartRecord>
    {
        public decimal Price
        {
            get { return Record.Price; }
            set { Record.Price = value; }
        }

        public string Duration
        {
            get { return Record.Duration; }
            set { Record.Duration = value; }
        }

        public string currencyCode 
        {
            get { return Record.currencyCode; }
            set { Record.currencyCode = value; }
        }

        public string thumnellImageLink
        {
            get { return Record.thumnellImageLink; }
            set { Record.thumnellImageLink = value; }
        }

        public string packageDetailsLink
        {
            get { return Record.packageDetailsLink; }
            set { Record.packageDetailsLink = value; }
        }
    }
}

Migrations.cs 

 

using Orchard.ContentManagement.MetaData;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;

namespace Holidays.Package
{
    public class Migrations : DataMigrationImpl {
        public int Create() {

            SchemaBuilder.CreateTable("HolidaysPackage", table => table
                .ContentPartRecord()
                .Column<decimal>("Price")
                .Column<string>("Duration", column => column.WithLength(50))
                .Column<string>("currencyCode", column => column.WithLength(50))
                .Column<string>("thumnellImageLink")
                .Column<string>("packageDetailsLink")
                );
            return 1;
        }

        public int UpdateFrom1(){
            ContentDefinitionManager.AlterPartDefinition("HolidaysPackagePart", part => part
                .Attachable());

            return 2;
        }
    }
}

HolidaysPackagePartHandler.cs

using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Holidays.Package.Models;

namespace Holidays.Package.Handlers
{
    public class HolidaysPackagePartHandler : ContentHandler
    {
        public HolidaysPackagePartHandler(IRepository<HolidaysPackagePartRecord> repository)
        {
            Filters.Add(StorageFilter.For(repository));
        }
    }
}

Table name is : Holidays_Package_HolidaysPackage

When i save, i got this message and no thing on my Content and database

Your Package-Holidays has been created.
Not found
The page you are looking for does not exist.

 

Developer
Jan 20, 2013 at 12:19 AM

I think you should rename your table name to: "HolidaysPackagePartRecord", since that's the name of your record class as well.

Jan 20, 2013 at 10:05 AM

Thank you it woks for me. I think we can mention any table name,

Developer
Jan 20, 2013 at 10:07 AM

Yes, just as long as the class name matches the table name.

Jan 24, 2013 at 5:45 PM

I am trying to save data using Controller in my custom module, but i can not save it out and not getting any error,

Services

using Holidays.Package.Models; using Orchard; using Orchard.ContentManagement; using Orchard.Security; using Orchard.Services; namespace Holidays.Package.Services { public class PackageInquiryService : IPackageInquiryService { private readonly IOrchardServices _orchardServices; public PackageInquiryService(IOrchardServices orchardServices) { _orchardServices = orchardServices; } public PackageInquiryPart SavePackageInquiry(Models.PackageInquiryPartRecord Record) { var packageInquiry = _orchardServices.ContentManager.New("PackageInquiry"); var packageInquieyPart = packageInquiry.As<PackageInquiryPart>(); packageInquieyPart.PackageTitle = Record.PackageTitle; packageInquieyPart.PackageRate = Record.PackageRate; packageInquieyPart.PackageDuration = Record.PackageDuration; packageInquieyPart.Remark = Record.Remark; packageInquieyPart.Adult = Record.Adult; packageInquieyPart.child = Record.child; packageInquieyPart.ContactNumber = Record.ContactNumber; packageInquieyPart.CurrencyCode = Record.CurrencyCode; packageInquieyPart.CustomerEmailAddress = Record.CustomerEmailAddress; packageInquieyPart.CustomerName = Record.CustomerName; packageInquieyPart.CustomerTitle = Record.CustomerTitle; packageInquieyPart.TravelDate = Record.TravelDate; _orchardServices.ContentManager.Create(packageInquiry); return packageInquieyPart; } } }

Controller:
 [System.Web.Mvc.HttpPost]
        [Themed]
        public ActionResult Save(PackageInquiryPartRecord Record)
        {
            _IPackageInquiryService.SavePackageInquiry(Record);
            return RedirectToAction("Index");
        }

Handlers
using Holidays.Package.Models;
using Orchard.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.ContentManagement.Handlers;

namespace Holidays.Package.Handlers
{
    public class InquiryPartHandler : ContentHandler
    {
        public InquiryPartHandler(IRepository<PackageInquiryPartRecord> repository)
        {
            Filters.Add(StorageFilter.For(repository));
            Filters.Add(new ActivatingFilter<PackageInquiryPart>("PackageInquiry"));
        }

    }
}

Models
PackageInquiryPart.cs
PackageInquiryPartRecord.cs
 

public PackageInquiryPart SavePackageInquiry(Models.PackageInquiryPartRecord Record)
       {
           var packageInquiry = _orchardServices.ContentManager.New("PackageInquiry");

        
           var packageInquieyPart = packageInquiry.As<PackageInquiryPart>();

           packageInquieyPart.PackageTitle = Record.PackageTitle;
           packageInquieyPart.PackageRate = Record.PackageRate;
           packageInquieyPart.PackageDuration = Record.PackageDuration;
           packageInquieyPart.Remark = Record.Remark;
           packageInquieyPart.Adult = Record.Adult;
           packageInquieyPart.child = Record.child;
           packageInquieyPart.ContactNumber = Record.ContactNumber;
           packageInquieyPart.CurrencyCode = Record.CurrencyCode;
           packageInquieyPart.CustomerEmailAddress = Record.CustomerEmailAddress;
           packageInquieyPart.CustomerName = Record.CustomerName;
           packageInquieyPart.CustomerTitle = Record.CustomerTitle;
           packageInquieyPart.TravelDate = Record.TravelDate;

           _orchardServices.ContentManager.Create(packageInquiry);

           return packageInquieyPart;


       }
Coordinator
Feb 10, 2013 at 10:27 PM
More details, please. What error are you getting?