N2 CMS for beginners

Topics: Developer Forum
Sep 27, 2008 at 12:36 AM
I'm a relatively new to visual studio but think N2 is brilliant and am looking for somebody that may be able to help me. I've played around with the template versions and have some degree of understanding of how they work but it would be good if I could get some advice as I cannot get my head around how to develop something from scratch. I'm trying to create a site that requires 2x different templates which I've worked out from a style point of view using different classes using the TemplateUrl but don't understand how to add new fields and implement a the News system. Any advice or references would be much appreciated.
Sep 27, 2008 at 3:56 AM
Edited Sep 27, 2008 at 4:02 AM
Hi, I'm also a beginner who has used N2 for nearly 1 week. Here are some advised that may be of help.
Unlike some other CMS, N2 creates a item by creating a new item class, which is a class derived from N2.ContentItem. The class cooperates with a aspx web page which can be set by TemplateUrl. If you want new fields, just add new properties in the item class. Here's some documents about this
To build a news system, here's my way to do it.
firstly, create a item class for news. it may have some properties like title, content, time, etc. also create a "view" for it, the aspx page.
then we need a container to list all the news. it's also a item class. maybe you would like to add a property in this class named "page size" to control the size of each page. For the reason I may need to display the list in several different pages, I create it as a user control. Here's some information about it:
and the core code to find all the news is somewhat like
    private void BindFAQs()
        IList<FAQItem> faqItems = Find.Items.Where.Type.Eq(typeof(FAQItem)).Select<FAQItem>();
        this.faqs.DataSource = faqItems;
Wherever you want the news list, you can add this user control to the page then it works.
Sep 27, 2008 at 2:27 PM
Zhangyaoxing is putting it quite nicely. As a starting point you could dig into one of the examples on the releases tab and add your own items. If you take "N2 Page Template.zip" and put it in ...\Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C# you can have some things set up for you. Also drop all the .snippet files into ...\Documents\Visual Studio 2008\Code Snippets\Visual C#. Then you can add editable properties to your item class by writing n2proptb+tab+tab.
Sep 28, 2008 at 1:52 PM
Thanks for the feedback guys - Zhangyaoxing I appreciate your step by step guidance as its really helpful. How do I then create the fields in the database - would edit/install create them? Or do I create them manually? I just want to use SQLite.
Sep 28, 2008 at 10:51 PM
You normally don't need to create fields in the database. If you use the Get & SetDetail methods in your property getter/setters the values will be stored in a name-value and you don't need to change the database schema.
Sep 29, 2008 at 9:35 AM
I think one of the problems that I'm having is that I'm using VS2005 - Do you guys know if the 2008 solution will open with Express Web Developer?
Sep 29, 2008 at 6:33 PM
With some work you might be able to open the source codes (n2.everything.sln). However, you don't need to. If you plan to build a site you can use the compiled release and open the 2005 solution.
Sep 29, 2008 at 8:18 PM
Edited Sep 29, 2008 at 10:51 PM
I'm still really struggling as I'm new to .net. I'm basically trying to create a site that has the following but cannot work out how to create the templates

1) Text Page Template - Headline, Image, Body (Editable text area) with a horizontal nav for the top level only.
2) Sub Text Page Template - As above but with a left hand navigation.
3) News Page Template - Main page to display the latest news with left hand nav for other stories.

The reason for this is because I want to use different style sheets.
Sep 29, 2008 at 9:07 PM
I recommend you take the time to get the hang of ASP.NET. I think www.asp.net may be a good way starting point. See if you can create some page mockups without using N2. Then you could take a look at how things are implemented in N2's functional templates.
Sep 30, 2008 at 1:56 PM
I've cracked it!!! Many thanks for all of the responses.