Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8820349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:35:12+00:00 2026-06-14T05:35:12+00:00

I am using Orchard CMS and the Bootstrap theme. I have been trying to

  • 0

I am using Orchard CMS and the Bootstrap theme. I have been trying to use the carousel built in bootstrap to work as shown in the following blog post: http://www.stevetaylor.me.uk/image-carousel-using-twitter-bootstrap-and-orchard-cms-projections. I have followed the tutorial but i cannot get my new layout file to appear in the query under grid and html list. I believe i have copied the code word for word but still can get it to work. Anybody please help with this as think it would be a great feature to add. if i get it to work i will request it gets added to the bootstrap theme here: http://orchardbootstrap.codeplex.com/

See code below:

CarouselLayoutForm.cs

using System;
using Orchard.DisplayManagement;
using Orchard.Forms.Services;
using Orchard.Localization;

namespace Orchard.Projections.Providers.Layouts {

public class CarouselLayoutForms : IFormProvider {
    protected dynamic Shape { get; set; }
    public Localizer T { get; set; }

    public CarouselLayoutForms(
        IShapeFactory shapeFactory) {
        Shape = shapeFactory;
        T = NullLocalizer.Instance;
    }

    public void Describe(DescribeContext context) {
        Func<IShapeFactory, object> form =
            shape => {

                var f = Shape.Form(
                    Id: "CarouselLayout",                        
                    _HtmlProperties: Shape.Fieldset(
                        Title: T("Html properties"), 
                        _ListId: Shape.TextBox(
                            Id: "outer-grid-id", Name: "OuterDivId",
                            Title: T("Outer div id"),
                            Description: T("The id to provide on the div element."),
                            Classes: new[] { "textMedium", "tokenized" }
                            ),
                        _ListClass: Shape.TextBox(
                            Id: "outer-div-class", Name: "OuterDivClass",
                            Title: T("Outer div class"),
                            Description: T("The class to provide on the div element."),
                            Classes: new[] { "textMedium", "tokenized" }
                            ),
                        _InnerClass: Shape.TextBox(
                            Id: "inner-div-class", Name: "InnerDivClass",
                            Title: T("Inner div class"),
                            Description: T("The class to provide on the inner div element."),
                            Classes: new[] { "textMedium", "tokenized" }
                            ),
                         _FirstItemClass: Shape.TextBox(
                            Id: "first-item-class", Name: "FirstItemClass",
                            Title: T("First item class"),
                            Description: T("The class to provide on the first item element."),
                            Classes: new[] { "textMedium", "tokenized" }
                            ),
                        _ItemClass: Shape.TextBox(
                            Id: "item-class", Name: "ItemClass",
                            Title: T("Item class"),
                            Description: T("The class to provide on the item element."),
                            Classes: new[] { "textMedium", "tokenized" }
                            )
                        )
                    );

                return f;
            };

        context.Form("CarouselLayout", form);

    }
}
   /*
public class CarouselLayoutFormsValitator : FormHandler {
    public Localizer T { get; set; }

    public override void Validating(ValidatingContext context) {
        if (context.FormName == "CarouselLayout") {
            if (context.ValueProvider.GetValue("Alignment") == null) {
                context.ModelState.AddModelError("Alignment", T("The field Alignment is required.").Text);
            }

            if (context.ValueProvider.GetValue("Columns") == null) {
                context.ModelState.AddModelError("Columns", T("The field Columns/Lines is required.").Text);
            }
            else {
                int value;
                if (!Int32.TryParse(context.ValueProvider.GetValue("Columns").AttemptedValue, out value)) {
                    context.ModelState.AddModelError("Columns", T("The field Columns/Lines must be a valid number.").Text);
                }
            }
        }
    }
}
*/

}

CarouselLayout.cs

using System;
using System.Collections.Generic;
using System.Linq;
using Orchard.ContentManagement;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Projections.Descriptors.Layout;
using Orchard.Projections.Models;
using Orchard.Projections.Services;

namespace Orchard.Projections.Providers.Layouts {
public class CarouselLayout : ILayoutProvider {
    private readonly IContentManager _contentManager;
    protected dynamic Shape { get; set; }

    public CarouselLayout(IShapeFactory shapeFactory, IContentManager contentManager) {
        _contentManager = contentManager;
        Shape = shapeFactory;
        T = NullLocalizer.Instance;
    }

    public Localizer T { get; set; }

    public void Describe(DescribeLayoutContext describe) {
        describe.For("Html", T("Html"),T("Html Layouts"))
            .Element("Carousel", T("Carousel"), T("Organizes content items in a carousel."),
                DisplayLayout,
                RenderLayout,
                "CarouselLayout"
            );
    }

    public dynamic RenderLayout(LayoutContext context, IEnumerable<LayoutComponentResult> layoutComponentResults) {

        string outerDivClass = context.state.outerDivClass;
        string OuterDivId = context.state.OuterDivID;
        string innerDivClass = context.state.InnerDicClass;
        string firstItemClass = context.state.FirstItemClass;
        string itemClass = context.state.ItemClass;

        IEnumerable<dynamic> shapes =
           context.LayoutRecord.Display == (int)LayoutRecord.Displays.Content
               ? layoutComponentResults.Select(x => _contentManager.BuildDisplay(x.ContentItem, context.LayoutRecord.DisplayType))
               : layoutComponentResults.Select(x => x.Properties);

        return Shape.Carousel(Id: outerDivId, Items: shapes, OuterClasses: new[] { outerDivClass }, 
                InnerClasses: new[] {innerDivClass}, FirstItemClasses: new[] {firstItemClass}, ItemClasses: new[] {itemClass});
    }
}
}

LayoutShapes.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Orchard.ContentManagement;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Mvc.Html;
using Orchard.Utility.Extensions;

namespace Orchard.Projections.Providers.Layouts {
public class LayoutShapes : IDependency {
    public LayoutShapes() {
        T = NullLocalizer.Instance;
    }

    public Localizer T { get; set; }

    [Shape]
    public void Carousel(dynamic Display, TextWriter Output, HtmlHelper Html, string Id, IEnumerable<dynamic> Items, 
                        IEnumerable<string> OuterClasses, IDictionary<string, string> OuterAttributes,
                        IEnumerable<string> InnerClasses, IDictionary<string, string> InnerAttributes, 
                        IEnumerable<string> FirstItemClasses, IDictionary<string, string> FirstItemAttributes, IEnumerable<string> ItemClasses,  IDictionary<string, string> ItemAttributes ) 
    {            
        if (Items == null) return;

        var items = Items.ToList();
        var itemsCount = items.Count;

        if (itemsCount < 1) return;

        var outerDivTag = GetTagBuilder("div", Id, OuterClasses, OuterAttributes);
        var innerDivTag = GetTagBuilder("div", string.Empty, InnerClasses, InnerAttributes);
        var firstItemTag = GetTagBuilder("div", string.Empty, FirstItemClasses, FirstItemAttributes);
        var itemTag = GetTagBuilder("div", string.Empty, ItemClasses, ItemAttributes);

        Output.Write(outerDivTag.ToString(TagRenderMode.StartTag));
        Output.Write(innerDivTag.ToString(TagRenderMode.StartTag));

        int i = 0;

        foreach (var item in items)
        {
            if (i== 0)
               Output.Write(firstItemTag.ToString(TagRenderMode.StartTag)); 
            else
               Output.Write(itemTag.ToString(TagRenderMode.StartTag)); 

            Output.Write(Display(item));
            Output.Write(itemTag.ToString(TagRenderMode.EndTag));
            i++;
        }

        Output.Write(innerDivTag.ToString(TagRenderMode.EndTag));

        Output.Write("<a href=\"#{0}\" class=\"carousel-control left\" data-slide=\"prev\">&lsaquo;</a>",id);
        Output.Write("<a href=\"#{0}\" class=\"carousel-control right\" data-slide=\"next\">&lsaquo;</a>",id);

        Output.Write(outerDivTag.ToString(TagRenderMode.EndTag));

        Output.Write("<script>$(function () {$('"+ Id +"').carousel();}); </script>");

    }

    static TagBuilder GetTagBuilder(string tagName, string id, IEnumerable<string> classes, IDictionary<string, string> attributes) {
        var tagBuilder = new TagBuilder(tagName);
        tagBuilder.MergeAttributes(attributes, false);
        foreach (var cssClass in classes ?? Enumerable.Empty<string>())
            tagBuilder.AddCssClass(cssClass);
        if (!string.IsNullOrWhiteSpace(id))
            tagBuilder.GenerateId(id);
        return tagBuilder;
    }

}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:35:13+00:00Added an answer on June 14, 2026 at 5:35 am

    Did you add your code to the module Orchard.Projections as explained?
    You need to add the files in Visual Studio and to save the project for them to be included in the .csproj (unless, the dynamic compilation won’t take the files in account), or you can build the module.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm using WCF WebAPI Preview 6 within my application (Orchard CMS). I'm trying
I am creating a website using Orchard CMS and I have an external .NET
I work on a project where we're considering using Orchard CMS . However, we
I have created a website on azure running Orchard CMS using a SQL Compact
I have setup a brand new Orchard CMS 1.5.1 site using Web Platform Installer
I have created an orchard cms blog with a url like www.testurl.com I would
I am trying to deploy Orchard using WebDeploy. Orchard has the following folder structure,
I have setup a VM (VMWEB-3) to test local development of Orchard CMS using
I am using MvcMailer with Orchard CMS in a module I created, and although
Let's say we have two pages in Orchard CMS. The homepage and the About

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.