Multiple Drop Zones Anybody?

Topics: Developer Forum, User Forum
Mar 9, 2009 at 7:39 PM
Hello,

I was wondering if anyone has gotten more than one dropzone working, somewhat explained in these 2 articles, and lots of questions about it but cant seem to find a solution.

http://mwpsk.mwpcms.se/dropzones.aspx 

I am trying to add a 2nd Drop Zone that I may have unique content in for each page.

Anyones help would be much appreciated.

Thank You,
TJ Havens
Apr 1, 2009 at 9:37 PM
Can someone please take a crack at making multiple dropzones work?

Thanks,
TJ havens
Apr 2, 2009 at 1:44 AM
Edited Apr 2, 2009 at 2:38 AM

Hi TJ,

I reckon there just needs to be a mechanism for "remembering" which dropzone "owns" a particular section.

At the moment, it's assumed there's only one dropzone on a page, so the dropzone control loads all dropzone sections
related to the page - by storing the dropzone id too, we can ensure correct allocation of sections to dropzones.

Changing property WebPage.SectionHolders (and the field in the WebPage.Data class) from a List<string> to List<DropZoneSectionInfo>, as described below, should achieve this.

public class DropZoneSectionInfo
{
    public string SectionId;
    public string DropZoneId;

    public ISection Section
    {
        get { return SectionLoader.GetInstance().LoadSection(SectionId); }
    }
}

 

 

The AddSectionHolder & RemoveSectionHolder methods also need to change, to accomodate this new structure.

There are some additional, minor changes required elsewhere too:
The dropzone.ascx.cs itself needs changes:
Page_Init - Ensure the dropzone control only loads it's own sections, (as dictated by this.ControlID == DropZoneSectionInfo.DropZoneId)
btnNewSection_Click - store dropzone id along with section id, in a new DropZoneSectionInfo

Also,

  • DropZoneAdmin.ascx.cs change btnDeleteSection_Click method to handle DropZoneSectionInfo's
  • Navigation.aspx.cs - CreateClone needs change
  • Administration/Sections.aspx.cs - again, change btnMoveSection_Click to handle DropZoneSectionInfo's

And that looks like it - I now have a working "multi-dropzone" site!  It could probably be improved, but seems to work...

I can provide copies of the changed files, if required.


HTH,

Jim.

Apr 2, 2009 at 6:17 PM
Jim,

Can you please provide copies of the changed files?

Thanks,
TJ Havens
Apr 2, 2009 at 10:57 PM
I've attached changed files to this workitem.

HTH,
Jim.
Apr 3, 2009 at 6:09 PM
Edited Apr 3, 2009 at 6:17 PM
Added a fix, as there was an error when deleting a section - same workitem.

Fixed code
DropZoneAdmin.ascx.cs

protected void btnDeleteSection_Click(object sender, EventArgs e)
{
    List<DropZoneSectionInfo> toRemove = new List<DropZoneSectionInfo>();
    foreach (DropZoneSectionInfo info in _page.DropZoneSections)
    {
        if (info.SectionId == _section.Section.SectionId)
            toRemove.Add(info);
    }

 

    foreach (DropZoneSectionInfo info in toRemove)
        _page.RemoveDropZoneSection(info);
       
    _section.Section.Delete();
    Response.Redirect(Request.RawUrl);
}

 

 

 

 

Apr 4, 2009 at 9:01 PM
Hello,

I get the following error:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1526: A new expression requires () or [] after type

Source Error:

Line 89:         section.SaveData();
Line 90: 
Line 91: _page.AddDropZoneSection(new DropZoneSectionInfo{ SectionId = section.SectionId, DropZoneId = this.ID });Line 92:         _page.SaveData();
Line 93:        

Source File: c:\GeneralShit\Clients\SCSA\Website\wwwSCSA\scsatheyard.com\UserControls\DropZone.ascx.cs    Line: 91

Thanks,
TJ Havens
Apr 5, 2009 at 1:30 PM
Edited Apr 5, 2009 at 1:31 PM
Change to:


Line 89:        section.SaveData();
Line 90:
Line 91:        DropZoneSectionInfo info = new DropZoneSectionInfo();
Line 91a:       info.SectionId = section.SectionId;
Line91b:        info.DropZoneId = this.ID;
Line91c:        _page.AddDropZoneSection(info);
Line 92:        _page.SaveData();



Problem due to .net 3.5 object initializer code.  Original code will work in a .net 3.5 codebase.  Above code required for original .net 2.0 codebase.


Kind regards,
Jim
Apr 15, 2009 at 3:34 PM
Hi. I've done som changes in the dropzones like adding a new feature that let's the control registerers it self. It's called SectionZones and will replace DropZones. It's is really easy to use.
Just add a reference to the usercontrol i Skinfile, and you can create how many sectionzones you like.

In Skinfile add:
<%@ Register tagPrefix="cc2" TagName="SectionZone"  src="~/UserControls/SectionZone.ascx" %>

And start creating SectionZones for eg
<cc2:SectionZone runat="server" SectionZoneID="Sidebar" ID="SectionZone1" />
Or
<cc2:SectionZone runat="server" SectionZoneID="LeftSidebar" ID="SectionZone2" />
Or.........

See my post at http://mwpsk.mwpcms.se/sectionzones.aspx

Regards //Rickard