/// <summary>
 /// Render inner component presentations
 /// </summary>
 /// <param name="region"></param>
 /// <param name="sb"></param>
 protected override void OutputComponentPresentations(Region region, StringBuilder sb)
 {
     sb.Append("<componentPresentations>\n");
      foreach (ComponentPresentationInfo cp in region.ComponentPresentations)
      {
          sb.Append("<componentPresentation>\n");
          this.OutputComponent(cp.Component, sb);
          this.OutputTemplate(cp.Template, sb);
          sb.Append("</componentPresentation>\n");
      }
      sb.Append("</componentPresentations>\n");
 }
        protected override void OutputComponentPresentations(Region region, StringBuilder sb)
        {
            // TODO: How to output component presentations???
            // Have some kind of flexible and pluggable region strategy that handles this???
            sb.Append("<componentPresentations>\n");

            foreach (ComponentPresentationInfo cp in region.ComponentPresentations)
            {
                // TODO: Handle dynamic components here aswell
                this.SetSharedParameter("innerRegion", cp.InnerRegion);
                sb.Append(this.Engine.RenderComponentPresentation(cp.ComponentUri, cp.TemplateUri));
            }

            sb.Append("</componentPresentations>\n");
        }
Ejemplo n.º 3
0
 protected void OutputRegion(Region region, StringBuilder sb)
 {
     sb.Append("<region name=");
     sb.Append(GetQuotedString(region.Name));
     sb.Append(">\n");
     this.OutputComponentPresentations(region, sb);
     if (region.Template != null)
     {
         this.OutputTemplate(region.Template, sb);
     }
     this.OutputConstraints(region, sb);
     sb.Append("</region>\n");
 }
Ejemplo n.º 4
0
        protected void OutputConstraints(Region region, StringBuilder sb)
        {
            sb.Append("<constraints>\n");

            if (region.ComponentTypes != null)
            {
                // TODO: Decouple the constraints further in the region (link component or similiar)

                // Right now only Editable Region Constraint is implemented
                //
                sb.Append("<editableRegionConstraint minOccurs=\"");
                sb.Append(region.MinOccurs);
                sb.Append("\" maxOccurs=\"");
                sb.Append(region.MaxOccurs);
                sb.Append("\">\n");
                sb.Append("<componentPresentationTypes>\n");
                foreach (ComponentType componentType in region.ComponentTypes)
                {
                    sb.Append("<componentPresentationType schemaId=\"");
                    sb.Append(componentType.SchemaUri);
                    sb.Append("\" templateId=\"");
                    sb.Append(componentType.TemplateUri);
                    sb.Append("\"/>\n");
                }
                sb.Append("</componentPresentationTypes>\n");
                sb.Append("</editableRegionConstraint>\n");
            }
            sb.Append("</constraints>\n");
        }
Ejemplo n.º 5
0
 // Default implementation, is overriden by subclasses
 //
 protected virtual void OutputComponentPresentations(Region region, StringBuilder sb)
 {
     sb.Append("<componentPresentations>\n");
     foreach (ComponentPresentationInfo cp in region.ComponentPresentations)
     {
         sb.Append(this.Engine.RenderComponentPresentation(cp.ComponentUri, cp.TemplateUri));
     }
     sb.Append("</componentPresentations>\n");
 }
        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");
        }
 private string RenderRegion(Region region)
 {
     this.SetSharedParameter("region", region);
     return this.Engine.RenderComponentPresentation(region.Component.Id, region.Template.Id);
 }