Customizing Default RoutePart via Module by inheriting and overriding properties but Showing two times on Page ContentType.

Topics: Administration, Core, Customizing Orchard, Writing modules
Sep 13, 2015 at 2:18 PM
Objective - To customize or add default URL of RoutePart in some cases just like in Blogs. Want to add foldername in URL. For Eg - http://localhost:1234/Orchardlocal/abc/ Orchard Version - 1.3

Customizing Default RoutePart via Module by inheriting and overriding properties but Showing two times on Page ContentType. I defined new RoutePartRecord and RoutePartDrivers by inheriting prebuilt route code and using same Views of RoutePart but whenever it renders it renders two times - One with mine drivers customization and one with RouteDriver.

I created mine CustomRoutePart : RoutePart and CustomRoutePartDriver : ContentPartDriver<CustomRoutePart > but whenever I call my driver, it calls RoutePartDriver as well and renders 2 times as I described above.


Could you please explain me working of inherited Drivers class and let me know solution to overcome this problem and showcase only one with mine customized view only.

Thanks
Sep 17, 2015 at 7:56 AM
Why don't you just attach the AutoRoutePart and configure it to use your default url?
Sep 17, 2015 at 5:05 PM
Can I do this by AutoRoutePart class? Do you have any recipe for this or provide me some description?

It seems I can override functionality by defining same name class in my Modules namespace. Found this code on google to use. Is it fine?

using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;

namespace Orchard.Autoroute.Models {
public class AutoroutePart : ContentPart<AutoroutePartRecord>, IAliasAspect {

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

    public bool UseCustomPattern {
        get { return Record.UseCustomPattern; }
        set { Record.UseCustomPattern = value; }
    }

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

    public string Path {
        get { return DisplayAlias; }
    }
}
}
Sep 21, 2015 at 7:51 AM
Edited Sep 21, 2015 at 7:51 AM
You don't have to code anything, just attach the autoroute part to you content type and configure it to use your foldername. There are tokens available in the autoroutepart to do it dynamically based on other properties.

Here is how the blogpost content type is configured:

Image