This project is read-only.

Project setup
Setup you database name and password in the config file and start up the application.

Create a pagetemplate
To create a pagetemplate is simple. Add a _Layout.YOURTEMPLATENAME.cshtml to www folder below Themes/www/Views.

Edit Templates.txt and add something like the following line:
_Layout.YOURTEMPLATENAME.cshtml,MYTEMPLATENAME,HEADER|SIDEBAR|CONTENT|SIDEBARRIGHT,<div id="template"><div id="templateHEADER">{HEADER}</div><div class="clear"></div><div id="templateSIDEBAR" class="zone">{SIDEBAR}</div><div id="templateCONTENT" class="zone">{CONTENT}</div><div id="templateSIDEBARRIGHT" class="zone">{SIDEBARRIGHT}</div><div class="clear"></div><div id="templateFOOTER">{FOOTER}</div></div>

You also add the markup for admin in this file.

Create Zones in a page
This is really the easy part. Just add @Zone("YourZoneName") anywhere in the template and it's done.

Create a Widget
It's really easy to create a widget in NWP intranet. Just describe the class with properties, add ActiveRecord attribute om class and set property info on each property. It will automatically add the new table in database.Create the controller with the same name and inherit WidgetBaseController<WidgetModel> and you done. See the code below:

using System;
using System.ComponentModel.DataAnnotations;
using Castle.ActiveRecord;
using NHibernate.SqlTypes;
using Castle.ActiveRecord.Attributes;

namespace NWP.Widgets
    public class Content : Widget<Content>
        public Content() : base() { }
        public Content(int id): base()
            WidgetId = id;

        [PrimaryKey(Generator = PrimaryKeyType.Increment)]
        public override int WidgetId { get; set; }

        [Property(NotNull = true)]
        public override int PageId { get; set; }

        [Property(NotNull = true)]
        public override string Zone { get; set; }

        [Property(NotNull = false)]
        public override bool IsGlobal { get; set; }

        [Property(NotNull = false)]
        public override bool Active { get; set; }

        [Property(NotNull = false)]
        public override string Domain { get; set; }

        [Property(NotNull = false)]
        public string Title { get; set; }

        [Property(NotNull = false)]
        public DateTime Created { get; set; }

        [Property(NotNull = false, ColumnType = "StringClob")]
        public string Html { get; set; }

        [Property(NotNull = false)]
        public override string SortOrder { get; set; }

        [Property(NotNull = false)]
        public override bool TrashBin { get; set; }

        [Property(NotNull = false)]
        public int Owner { get; set; }

        public override string Icon { get { return "file-edit"; } }
The controllers code
using NWP.Widgets;

namespace NWP.Controllers
    public class ContentController : WidgetBaseController<Content>
This will automatically create a ViewModel for your view.
When you click edit or save it will automatically call the basecontroller

The "Icon" Property let the widget be displayed in dashboard with icon you choosed. If the Icon property is empty it will not show.
Create a view below Views/Widgets withe same name as your widget class.
For eg. _Content.cshtml and put the modeldata in it.

@model NWP.Widgets.Content @Html.Raw(Model.Html)

Last edited Aug 19, 2012 at 4:23 PM by rickardmagnusson, version 13


No comments yet.