This project is read-only.

Adapting changes after new release

Topics: Developer Forum
Sep 15, 2008 at 8:32 AM
Hi,

After every release, I try to adapt all your changes to make the current website as compatible with the newest N2 version as possible. This all worked out fine, until now (but I hope you can help me out).

I've written my own templates project (with a lot of copied code such as startpage, rootpage, textpage, etc). I did this because all the template codes required the Top+Submenu.master file. I didn't (and still don't) want to use that file. However, most of the templates link to the masterpage file in the header of the aspx file.

How can I safely use the newest templates project (including the startpage, textpage, etc) so I only have to create the custom parts that are required?
Sep 15, 2008 at 5:29 PM
Good question. To only change master page I'd suggest using the configuration (change to something you like):
    <templates masterPageFile="~/Templates/UI/Layouts/Top+SubMenu.Master" />

To tweak functionality on existing types there's the option of overriding and replacing definitions:
[ReplacesParentDefinition]
public class MyTextPage : TextPage
{
  public override string TemplateUrl
  {
    get{ return "/path/to/my/template.aspx";}
  }
}

The most safe option is to avoid putting your own code in the /templates folder since that's where updates are most likely to appear.
Sep 15, 2008 at 8:26 PM
So basically you are saying I should use the wwwroot code as is and copy the whole stuff into my project?

The problem (this morning) was that I don't have the left, recursiveleft, etc parts. However, I have added these to the masterpage to make it look the same as the Top+SubMenu.master.

I use a ASP.NET Web Application, not a ASP.NET Web Site (which actually is a "big" difference). I will see what I can do with the templates folder.
Sep 16, 2008 at 7:30 AM
What kinds of differences do you run into using the web site model? How mutch do you use from templates?
Sep 16, 2008 at 7:34 AM
Edited Sep 16, 2008 at 7:34 AM
For the current site I am developing, I used News, Text, Columns, (a customized AJAX supported) Search and some custom controls. However, I don't want to rewrite (and update) these controls (pages) every time when an update occurs (I update regularly via the svn repos).

Do you think it's best to keep my "custom developed" templates directory in the web project and update this to reflect the changes?
Sep 16, 2008 at 2:45 PM
Ok, I have been struggling for some time, but I think I found the right way now :)

I have completely removed the Templates folder, recreated it and added the predefined Templates (from N2) into that. I now treat the directory as the Edit directory (it's there, don't touch it). Then, I moved all the custom templates I have written to the root instead of the directory templates (so ~/Templates/Admin/ became ~/Admin/).

For now, everything seems to work pretty good, except:

I set the masterpage, but that doesn't help much. I use this code:

<

 

templates mailConfiguration="Fake" masterPageFile="~/MasterCMS.master" />

 

However, when I navigate to the existing Text.aspx (template item), it complains that the MasterPage contains an unknown item. As soon as I removed the MasterPage and Theme from the template holder (Text.aspx), everything worked smooth.

Sep 16, 2008 at 5:13 PM
Can you post a stack trace? Could it be that the page use a content placeholder that doesn't exist in your master page?
Sep 17, 2008 at 7:33 AM
Yesterday was a hard day (I see now), nothing is wrong when I restore the declaration of the MasterPageFile in the templates. All is working fine, probably I forgot an item in the masterpage or something like that.