This project is read-only.

Help with advice/directioning

Topics: Developer Forum
Feb 18, 2008 at 4:43 PM
Edited Feb 18, 2008 at 4:44 PM

I have started working on my first N2 implementation. Exciting! :-)

QUESTION 1: I have various modules which will appear in the lefthand column. They will will be reused on different pages in different order, and some of them will be just text + link and other will contain some logic like search, weather forecast fetching+rendering and so on. You can see the example on static mock ups here:
1. Page 1
2. Page 2
I guess that N2 parts is the best candidate to look into for implementation of these modules. If so, can you direct me to the example or docs where I can learn more about the subject. I want to create modules which will enable end user to add them to the lefthand column from some repository or create below that page object (whichever is the way parts work).

QUESTION 2: On the example web I have up and running there is no submenu which gets extended from the upper right corner of content window in edit mode. Since it is parts related I guess it has to be turned on, or is turned on automatically when parts are present. Can somebody please direct me to the example or docs for this thingy as well.

Thanx and wish me luck :-)
Feb 18, 2008 at 7:36 PM
Hi Milosmalic,

You're in luck! There are already a few resources on this topic. You might already have looked at defining parts and creating parts templates. There is also a minimal example and the templates project which might be more complicated to start with.

Secondly I think you're referring to the control panel thingie that slides in and out. Add this to your master page:
		//this needs to be configured in web.config <add tagPrefix="n2" namespace="N2.Parts.Web.UI.WebControls" assembly="N2.Parts"/>
		<n2:SlidingCurtain runat="server">
			<n2:DragDropControlPanel runat="server" QuickEditLink-Visible="false" />

And lastly good luck!

Feb 24, 2008 at 4:22 PM
Edited Feb 24, 2008 at 4:40 PM
Cristian thanx!

Adding the additional menu worked like a charm.

Then I moved to parts and templates and have a question. I stared with a basic example website. Then using N2.Example.Parts example I have moved AbstractItem and TextItem to App_Code and TextItem (ascx and cs) to Parts folder in the example website solution (the basic one). Master page has two ContentPlaceHolders, and within their corresponding controls I entered two zones (one per placeholder) named MainZone and LeftZone.

When I run the solution and go to edit mode -> organize parts, zones are displayed as gray bars as in N2.ExampleParts, but the content sliding menu doesn't show TextItem. Only thing visible is "Done organizing" item. Am I missing something to get TextItem listed in sliding menu? Sorry if I'm asking lame questions, but I have been comparing the way it is done (and working) in N2.Example.Parts and it should work.

Feb 24, 2008 at 4:53 PM
I'm thinking this has to do with how the definitions are set up. The containing page definition must have the same zone the TextItem is allowed to be placed in. E.g.

[N2.Integrity.AvailableZone("The main content area", "MainZone")]
[N2.Integrity.AvailableZone("Left of the main content area", "LeftZone")]
public class MyPage : ContentItem
[N2.Integrity.AllowedZones("MainZone", "LeftZone")]
public class TextItem : ContentItem

Another possible cause might be the RestrictParents attribute. Don't worry about asking. I'm aware that this setup isn't the most obvious. Based on input like this I'll probably simplify or improve documentation.

Feb 24, 2008 at 5:28 PM
One step further. Yes, the parts are visible now after I added two suggested tags to page base class.

But now, when I go to Edit -> Organize Parts -> drag part from sliding menu; it wont drop in selected zone. When I drag part from the menu to the gray zone image, it changes to double height, looking like the part will be accepted but when I release mouse click nothing happens.

I have tried to put zones directly on master page and on the page control aspx. Is this related to RestrictParents? I don't see this attribute anywhere set explicitly in the code.
Feb 24, 2008 at 6:30 PM
After some more investigating here is additional info that might give you a clue to the glitch:

When I go to Edit mode, and create new item as child of some page, then go to Zone tab and select LeftZone (as in previous posts), and then switch back to Type tab - TextItem part is available to create. When I create it, and Save & Publish and then go for "Organize Parts", it is available as a part in correct zone. Delete button on part launches confirmation dialog but doesn't delete part after OK, and Edit icon doesn't react likewise.

When I edit the page which is parent to a part, I can use right Zone command to select and edit the part, but there is no delete option there, right?

The parts created through Edit -> Zone commands behave draggable like, but when I drop them somewhere they don't stick.
Feb 24, 2008 at 7:29 PM
Are you by any chance using ie6? I just noticed that the color doesn't change when dragging items in that browser. Any difference with firefox?
Feb 24, 2008 at 9:38 PM
Nope. I'm using IE7 and Firefox (always checking everything in both browsers).

Also, as I wrote in one of previous posts when I run N2.Example.Parts project the parts drag'n'drop works ok.

My first guess is that I might be missing some javascripts in /Edit since I continued development of website using basic example project as start. But then when I drag'n'drop in that project no error raises, it just doesn't execute.

As a first try I deleted all dll's from my project (ex example) and copied those from N2.Example.Parts just in case but it didn't help. Maybe I should run file compare on /Edit. What is the first place you would look if you were me?
Feb 24, 2008 at 9:39 PM
Edited Feb 24, 2008 at 9:41 PM

I just rechecked both projects in both browsers, and N2.Example.Part works fine in both browsers. The edit click on the small icon when page is edited opens ajax edit dialog and changes are saved.
Feb 24, 2008 at 10:13 PM

<add name="n2initializer" type="N2.Web.InitializerModule,N2"/>

<add path=".n2.ashx" verb="" type="N2.Web.AjaxRequestHandler, N2" />
Feb 25, 2008 at 8:10 AM
Ahh, that one.. Great.
Apr 3, 2009 at 2:40 PM
Hey guys, I was wondering as a kind of addition to milosmalic's original post. Is it possible to create a part which can be customised by parameters given to it while editing in the CMS?

An example I am thinking of is say you had a News item, and you wanted to have a News part which could show the latest n news items by title (2,3,5 etc), you could also decide that you want to show only a certain type of news (providing you had customised this News item); or have different display options like showing an image title and summary for each article, or just the title as a link.

I'm thinking maybe I can do this along similar lines to the way the poll is configured.. I'll investigate, but if I am off along the wrong track please feel free to let me know.

P.s. I love N2! :)