Orchard CMS: Should I add a new layer for each page when the specific content for each page is distributed in different columns?

Suppose each page above the page title needs a different main image. In addition, I need to place the images on the page in the left column, and the text of the page in the right pane. In the right and left columns, I also want to use layer specific content.

I don’t see how I can achieve this without creating a layer for each page of the site, but then I get an excess of layers that serve only one page, which seems too complicated.

What am I missing?

If there is a way to do this using parts of the content, it would be great if you could point me to tutorials, blogs, videos to help solve this problem.

NOTE:

Sitefinity does a great job of this, but I find that Orchard is a lot easier to build a module, as well as the fact that MVC is a lot easier for me.

Orchard is free, I understand (and appreciate) that. Just hoping that as the product develops, will it be easier?

In other words, I hope for the best of all worlds ...

+5
source share
2 answers

1.5, , . , . . , , , a.k.a. randompete. :

ZoneProxyBehavior.cs:
=====================

using System;
using System.Collections.Generic;
using System.Linq;
using ClaySharp;
using ClaySharp.Behaviors;
using Orchard.Environment.Extensions;

namespace Downplay.Origami.ZoneProxy.Shapes {
    [OrchardFeature("Downplay.Origami.ZoneProxy")]
    public class ZoneProxyBehavior : ClayBehavior {

        public IDictionary<string, Func<dynamic>> Proxies { get; set; }

        public ZoneProxyBehavior(IDictionary<string, Func<dynamic>> proxies) {
            Proxies = proxies;
        }

        public override object GetMember(Func<object> proceed, object self, string name) {

            if (name == "Zones") {
                return ClayActivator.CreateInstance(new IClayBehavior[] {                
                    new InterfaceProxyBehavior(),
                    new ZonesProxyBehavior(()=>proceed(), Proxies, self)
                });
            }

            // Otherwise proceed to other behaviours, including the original ZoneHoldingBehavior
            return proceed();
        }

        public class ZonesProxyBehavior : ClayBehavior {
            private readonly Func<dynamic> _zonesActivator;
            private readonly IDictionary<string, Func<dynamic>> _proxies;
            private object _parent;

            public ZonesProxyBehavior(Func<dynamic> zonesActivator, IDictionary<string, Func<dynamic>> proxies, object self) {
                _zonesActivator = zonesActivator;
                _proxies = proxies;
                _parent = self;
            }

            public override object GetIndex(Func<object> proceed, object self, IEnumerable<object> keys) {
                var keyList = keys.ToList();
                var count = keyList.Count();
                if (count == 1) {

                    // Here the new bit
                    var key = System.Convert.ToString(keyList.Single());

                    // Check for the proxy symbol
                    if (key.Contains("@")) {
                        // Find the proxy!
                        var split = key.Split('@');
                        // Access the proxy shape
                        return _proxies[split[0]]()
                            // Find the right zone on it
                            .Zones[split[1]];
                    }
                    // Otherwise, defer to the ZonesBehavior activator, which we made available
                    // This will always return a ZoneOnDemandBehavior for the local shape
                    return _zonesActivator()[key];
                }
                return proceed();
            }

            public override object GetMember(Func<object> proceed, object self, string name) {
                // This is rarely called (shape.Zones.ZoneName - normally you'd just use shape.ZoneName)
                // But we can handle it easily also by deference to the ZonesBehavior activator
                return _zonesActivator()[name];
            }
        }
    }
}

ZoneShapes.cs:
==============


using System;
using System.Collections.Generic;
using Orchard.DisplayManagement.Descriptors;
using Orchard;
using Orchard.Environment.Extensions;

namespace Downplay.Origami.ZoneProxy.Shapes {
    [OrchardFeature("Downplay.Origami.ZoneProxy")]
    public class ZoneShapes : IShapeTableProvider {
        private readonly IWorkContextAccessor _workContextAccessor;
        public ZoneShapes(IWorkContextAccessor workContextAccessor) {
            _workContextAccessor = workContextAccessor;
        }

        public void Discover(ShapeTableBuilder builder) {

            builder.Describe("Content")
                .OnCreating(creating => creating.Behaviors.Add(
                    new ZoneProxyBehavior(
                        new Dictionary<string, Func<dynamic>> { { "Layout", () => _workContextAccessor.GetContext().Layout } })));
        }
    }

}

, Layout@ , , Layout@BeforeContent:1.

+5

:

Bertrand Le Roy ( ) , 3 , bodypart Core/Common.

ContentType ContentParts, autoroute bodypart .., , Content Orchard Pages, , .

ContentType a View.

, Views. ZoneProxy ContentPart (Parts_MainImage, Parts_RightContent, Parts_LeftContent) , . .

Sitefinity, , , .

, ContentParts, BodyPart TextField, , Shape, , ZoneProxy , . ContentParts JUST, . , ZoneProxy.

, Orchard. Wingspan.Views.

12 2012 , .

, , .

EDIT:

, (LeftContent, RightContent, MainImage ..) , .

, , .

ContentType, .

( Placement.info), , , MainImage . , , , 1, 2 ..

, , TextField, . , , TextFields, , ZoneProxy. , .

+4

All Articles