This project is read-only.

new ContentPages, Themes and CSS

Topics: Developer Forum, User Forum
Nov 29, 2008 at 6:14 PM

I'm trying to start with N2 and after a whole day of hair pulling I'm about to give up... I'm trying to use the Templates example and it's infuriating as hell. 
I'm trying to do what seemed like a simple thing - define a new Page inherited from AbstractContentPage which would show the list of classes studied at the university, and then also a new Page that would have more information about those classes. 
Since this looked almost the same as what the current News and NewsItem look like I copied most of the code from there. 
The new items are seen in the edit interface and I can create new ones, yet when they show they have no CSS associated with them. 
I've tried looking everywhere on how to set this, but I'm lost - everything seems to be same as for News and NewsItem, yet the theme's css file is not included. 
So, I've tried copying the master page to a different directory and including it in the MyProject solution and using that, but with the same result. 

I've seen in the top+submenu.master the following:
<asp:ContentPlaceHolder ID="Head" runat="server" />

which I suppose is what injects the approapriate css files? 
I suppose I am doing something wrong somewhere, yet for the life of me I cannot figure it out. 
This is the definition of my class:
    public class PredmetZaUrnikItem : AbstractContentPage

I've also tried searching the web.config to see where the main theme is being set, yet again I could not find anything. It seems that the Stripes theme is being used elsewhere, yet how is this setup? 

On the whole if there could be some more documentation (or any ! :) ) on how to actually use the Templates examples with a different design than the one that is baked in, it would be very helpful! 

Nov 29, 2008 at 7:31 PM
oh, and the example from MyProject - MyPage doesn't work:
The file '/Layouts/ThreeColumns.Master' does not exist.

since it seems to reference nonexistent master page - so I cannot use it to see how it should be done...
Nov 29, 2008 at 7:47 PM
Hi clarity. I'll try to create a tutorial on this topic. Meanwhile, to create the course list I'd do someting like this:

Define the content item:

    public class CourseList : AbstractContentPage
       public override string TemplateUrl { get { return "~/Views/CourseList.aspx"; } }

Create the CourseList.aspx:

<%@ Page MasterPageFile="~/Templates/UI/Layouts/Top+SubMenu.master" Language="C#" AutoEventWireup="true" CodeBehind="CourseList.aspx.cs" Inherits="MyProject.Views.CourseList" %>
<asp:Content ContentPlaceHolderID="Content" runat="server">
    <h1><%= CurrentPage.Title %></h1>
   <!-- This is where I would create a list of the child pages -->

And it's codebehind, CourseList.aspx.cs:

    public partial class CourseList: N2.Templates.Web.UI.TemplatePage<Items.CourseList>

If you inherit from TemplatePage you will get the site's styles applied. And by the way. The style is selected when editing the start page.

Hope this helps. Please ask more specific questions as they come up.
Dec 3, 2008 at 9:21 PM
Thank you, this solved the problem! 

Now I'm struggling with a few more... :( I'm trying to figure out which version to actually use, as everyone I tried has some issues.
If i download the templates example, I can build it ok and it seems to work except I can't delete parts when I'm organizing a page - when I check in firebug I see that the page delete.n2.ashx returns a 500 internal server error. - "There is a problem with the resource you are looking for, and it cannot be displayed."

Since I am not quite sure to debug this, I've tried to use other versions. I downloaded the n2-source version and did build everything and  Prepare_Depedencies and when I try to run the example I get the following error:

Could not load file or assembly'NHibernate.Caches.SysCache2' or one of its dependencies. The systemcannot find the file specified.

Description: Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details: System.IO.FileNotFoundException:Could not load file or assembly 'NHibernate.Caches.SysCache2' or one ofits dependencies. The system cannot find the file specified.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'NHibernate.Caches.SysCache2' could not be loaded.

=== Pre-bind state information ===LOG: User = NT AUTHORITY\NETWORK SERVICELOG: DisplayName = NHibernate.Caches.SysCache2 (Partial)LOG: Appbase = file:///C:/svn/N2_Source/examples/TemplatesSite/wwwroot/LOG: Initial PrivatePath = C:\svn\N2_Source\examples\TemplatesSite\wwwroot\binCalling assembly : NHibernate, Version=, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.===LOG: This bind starts in default load context.LOG: Using application configuration file: C:\svn\N2_Source\examples\TemplatesSite\wwwroot\web.configLOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v2.0.50727\Aspnet.configLOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).LOG: The same bind was seen before, and was failed with hr = 0x80070002.

Stack Trace: 

Ok, no idea what happened to this, so I try with the svn version.
Everything seems to work fine, except when I click on Organize parts on the start page nothing happens. 
Like, I don't get the usual screen where I can move parts around...  
On the Calendar page I can however - except I can't get rid of the login box - but I am not sure if this is by design... 
On a normal content page I cannot do organize parts again...

So, at this point I'm quite at a loss as to how to proceed. :( 
Which version is actually the best one to use? 
Dec 3, 2008 at 9:30 PM
oh, and I forgot to mention - I'm using Visual studio 2008 Enterprise edition on Vista SP1 and the site is deployed using IIS 7 on the same machine.
Dec 3, 2008 at 9:57 PM
The NHibernate problem is because a file (probably SysCache2) is not in the bin folder for the project. That is corrected in Prepare Dependencies script in the SVN source that you downloaded.
You could try to copy the dll from the other source bin after running prepare dependencies for resolving the first problem.

I can confirm the second problem with the Organize Parts on the start page with the source I retrieved from subversion last week. Templates project running in debug mode from the source project. (N2-Everything-vs2008.sln)
However the "Zones button" in the edit mode works fine and does exactly the same thing, so you could use that.

I currently develop against the "binary templates distribution". I can add and remove parts from the pages in the Organize Page mode.

Dec 3, 2008 at 11:12 PM
You can find nhibernate.caches.syscache2 in the lib folder. Copy it manually to the wwwroot/bin.

Hi, it would seem there is a bug with organizing the start page in the trunk version. Is it the one you are using? Thanks for finding I'll look into this.

The released source zip ( seems to work for me. I had to copy NHibernate.Caches.SysCache2 and System.Data.SQLite into the site's bin though.

The login is added to all pages since it's in the recursive zone on the start page. Until the drag'n'droppy is fixed you can remove it by enabling non-page items in the settings (the wrench in the toolbar) and then deleting the node with a key icon.
Dec 3, 2008 at 11:13 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.