private void OutputRegions(StringBuilder sb)
        {
            sb.Append("<regions>\n");
            IComponentPresentationList componentPresentations = this.GetComponentPresentations();

            Region region = null;
            Region innerRegion = null;

            int index = 0;
            foreach (Tridion.ContentManager.Templating.ComponentPresentation componentPresentation in componentPresentations)
            {
                Component component = new Component(componentPresentation.ComponentUri, Engine.GetSession());
                ComponentTemplate template = new ComponentTemplate(componentPresentation.TemplateUri, Engine.GetSession());
                Log.Debug("Checking component of type: " + component.Schema.Title);

                // TODO: How to handle region schemas?? What pattern to look for??? Find a more generic approach than looking on the schema title

                if (component.Schema.Title.Equals("DD4T Lite Region"))
                {
                    if (region != null)
                    {
                        sb.Append(this.RenderRegion(region));
                    }
                    region = new Region(component, template);
                    innerRegion = null;
                }
                else if ( innerRegion != null && innerRegion.Accept(component, template) )
                {
                    innerRegion.AddComponentPresentation(new ComponentPresentationInfo(component, template));
                }
                else if (region != null)
                {
                    innerRegion = null; // Clear inner region
                    Log.Debug("Adding component: " + component.Title + " to region: " + region.Name);
                    ComponentPresentationInfo cpInfo = new ComponentPresentationInfo(component, template);
                    region.AddComponentPresentation(cpInfo);
                    if (this.IsContainerComponent(template))
                    {
                        innerRegion = new Region(this.GetInnerRegion(template), index);
                        cpInfo.InnerRegion = innerRegion;
                    }
                }
                index++;
            }
            if (region != null)
            {
                Log.Debug("Outputting region: " + region.Name);
                sb.Append(this.RenderRegion(region));
            }
            sb.Append("</regions>\n");
        }
示例#2
0
 public void AddComponentPresentation(ComponentPresentationInfo cp)
 {
     this.componentPresentations.Add(cp);
 }