This project is read-only.

Adding Zone to Start Page

Topics: Developer Forum
Feb 5, 2009 at 7:31 PM
I'm using the templates project as a base. In fact 90% of what I need could be done by just using templates and creating a new skin. Now I did need to make some changes to templates to get the last stuff right. Now I wonder if there is some way that I could improve on how I did the changes to be more update-proof.
What did I need:
I needed to have a zone as wide as the footer, being able to take dropped content. In my case I added a three column container based on the default two columns "Columns.ascx". That three column container is dropped on the just below footer zone.
Now I also needed the zone to be avaliable on the front page.

Here's what I've done:
I've added a zone to the Master like this:
<div id="prefooter">
                <asp:ContentPlaceHolder ID="PreFooter" runat="server">
                    <n2:DroppableZone ID="zpf" ZoneName="PreFooter" runat="server" />
                </asp:ContentPlaceHolder>
            </div>
And placed it just above the footer div.

I have my three column container being droppable there like this:
[Definition("Three column container", "ThreeColumns")]
    [AvailableZone("Left", "ColumnLeft"), AvailableZone("Center", "Content"), AvailableZone("Right", "ColumnRight")]
    [AllowedZones("Content", "PreFooter")]
    public class ThreeColumns : AbstractItem
{...

Now in order to have the dropzone avaliable in the start page, I first tried to replace StartPage by doing this:
    [Definition("MyStartPage", "StartPage")]
    [AvailableZone("Before the footer", "PreFooter")]
    [ReplacesParentDefinition]
    public class MyStart : StartPage
    {
    }
Now this made nothing to the already existing start page, and when I tried to create another start page I got an exception complaining about it being a TextItem thus not castable to StartPage or something like that.

To solve this I now have changed the original StartPage definition like this:
[AvailableZone("Site Wide Top", Zones.SiteTop), AvailableZone("Site Wide Left", Zones.SiteLeft), AvailableZone("Site Wide Right", Zones.SiteRight), AvailableZone("Before Footer", "PreFooter")]
    public class StartPage : LanguageRoot, IFileSystemContainer, ISitesSource

Simply adding PreFooter to the avaliable zones. Then I recompiled and voila, it works.

Now I feel that there is a great possibility that this wrecks when the Templates Project gets updated and my new zone gets removed from StartPage.
What is "the right way (tm)" to do this?
Feb 5, 2009 at 10:09 PM
Is there are right way? The override and replace you mention is what I've been suggesting. Can you post a stack trace of your error, it might be something else causing problems.

What I'm planning for the next version is removing the requirement for AvailableZone and AllowedZones. The controls on the tempalte would be in charge of that. This would simplify quite a bit.

Another improvement is extension point that would allow you to redefine the aspx template for any item.

I think these changes would help in this scenario and possibly bring the percentage up to 92%.
Feb 5, 2009 at 11:04 PM
Actually now when I tried it again, nothing shows up when I try to create another child to the root node. By that I mean the list where one selects a template is empty.
(I haven't downloaded any updates since 2008-11-25, maybe there are important updates missing on my end?)