This project is read-only.

N2 cms FAQs

Topics: Developer Forum, User Forum
Jun 9, 2008 at 2:55 PM
hi,

I am new to N2 and its great, i have lots of experiences with CMSs, N2 is great, i have a few questions.

1. How do i prevent the root item from being deleted, likewise the main pages of the site in the cms. Those pages being deleted will mean no site at all, i want to prevent
deleting of the the main pages and the root page and also the trash can

2. I created a project and added the N2 dlls and the edit folder to it, how do i created user management sections. I know it has something to do with membership but how do i go about
it in N2.

3.I have created a content item for news. I am having trouble creating the published date, this is what i have created:
[N2.Details.EditableTextBox("Published", 20)]
public override DateTime Published
{
     get { return base.Published; }
     set { base.Published = value; }
}
   I get this error message when compiling: 'MyProject.ContentItems.News.Published': type must be 'System.DateTime?' to match overridden member 'N2.ContentItem.Published'
Jun 9, 2008 at 4:56 PM
1. The Root Item and the Startpage cannot be deleted, that is built in the framework.
2. See http://code.google.com/p/n2cms/source/browse/trunk/docs/releases/upgrade_1.3.5.txt, the part begins with "Change roles and membership providers:"
3. Try
    [N2.Details.EditableTextBox("Published", 20)]
    public override DateTime? Published
    {
         get { return base.Published; }
         set { base.Published = value; }
    }   
Jun 9, 2008 at 6:12 PM
         1. Well what about preventing of deleting of main pages
         2. http://code.google.com/p/n2cms/source/browse/trunk/docs/releases/upgrade_1.3.5.txt, this only gives information for vs 2008, i am using vs 2005
         3. It works ... :)

MartijnRasenberg wrote:
1. The Root Item and the Startpage cannot be deleted, that is built in the framework.
2. See http://code.google.com/p/n2cms/source/browse/trunk/docs/releases/upgrade_1.3.5.txt, the part begins with "Change roles and membership providers:"
3. Try
    [N2.Details.EditableTextBox("Published", 20)]
    public override DateTime? Published
    {
         get { return base.Published; }
         set { base.Published = value; }
    }   



Jun 9, 2008 at 7:36 PM

Hi adomovic. Could you explain about main pages? I'm not following. What differientiate them from a start page or a "secondary" page.

The membership providers are configured in web.config.

These are the sections in question:
<system.web>...
    <membership defaultProvider="ContentMembershipProvider"> <providers> <clear/> <add name="ContentMembershipProvider" type="N2.Security.ContentMembershipProvider, N2.Security" /> </providers> </membership> 
    <roleManager enabled="true" defaultProvider="ContentRoleProvider"> <providers> <clear/> <add name="ContentRoleProvider" type="N2.Security.ContentRoleProvider, N2.Security" /> </providers> </roleManager>
</system.web>

Jun 10, 2008 at 8:18 PM
hi,

Let me explain better: let use the structure for example
Root
    About us
          page one
          page two
    What we do
    Contact us


Now looking at the above, main pages will be About us, What we do and Contact us. I do i prevent deleting of those items I have a few more questions
1.
[N2.Details.EditableFreeTextArea("Content", 4, Required = true)]
        public virtual string NewsContent
        {
            get { return (string)(GetDetail("NewsContent") ?? string.Empty); }
            set { SetDetail("NewsContent", value); }
        }
In the above i have set the req. = true for the editablefreetextarea but when u are creating a new item,
it shows an error message even when you have text in the editablefreetextarea field.

2. I have custom date picker , how can i create a definition for it.
3.
        [N2.Details.EditableTextBox("Published", 20, Required=true)]
        public override DateTime? Published
        {
            get { return base.Published; }
            set { base.Published = value; }
        }
How do i validate the date with this data field definition, because if i enter a text in the field i page generates an asp.net error message.

   
Jun 11, 2008 at 12:18 AM
Edited Jun 11, 2008 at 12:18 AM
Aha, okay. The easiest is probably to use the item deleting event on N2.Context.Persister and set e.Cancel = true in this situation.

1. Hmm, I've got reports of this error before but I havn't been able to reproduce it. What browser are you using?
2. Try [Editable("My Date", typeof(MyDatePicker), "SelectedDate", 100)]
3. Either use [WithEditablePublishedRange] public class News...
or use the RegularExpression properties on the EditableTextBox attribute. Maybe this documentation about custom editors can be of intereset. It can also be used to add better validation.

adomovic wrote:
hi,

Let me explain better: let use the structure for example
Root
    About us
          page one
          page two
    What we do
    Contact us


Now looking at the above, main pages will be About us, What we do and Contact us. I do i prevent deleting of those items I have a few more questions
1.
[N2.Details.EditableFreeTextArea("Content", 4, Required = true)]
        public virtual string NewsContent
        {
            get { return (string)(GetDetail("NewsContent") ?? string.Empty); }
            set { SetDetail("NewsContent", value); }
        }
In the above i have set the req. = true for the editablefreetextarea but when u are creating a new item,
it shows an error message even when you have text in the editablefreetextarea field.

2. I have custom date picker , how can i create a definition for it.
3.
        [N2.Details.EditableTextBox("Published", 20, Required=true)]
        public override DateTime? Published
        {
            get { return base.Published; }
            set { base.Published = value; }
        }
How do i validate the date with this data field definition, because if i enter a text in the field i page generates an asp.net error message.

   



Jun 11, 2008 at 7:48 AM


libardo wrote:
Aha, okay. The easiest is probably to use the item deleting event on N2.Context.Persister and set e.Cancel = true in this situation.

Hi,

wouldn't it be a nice feature if the actions that can be performed on a ContentItem via the contextmenu can be disabled by disallowing roles and/or users?
i.e. if the loggedin user is revoked the right to delete an item, the Delete-option would be disabled and if the user-group would have been revoked the right to copy an item that option would be disabled?


Just a thought

Martijn
Jun 11, 2008 at 6:40 PM
Good idea. So far I've avoided action based authorization to keep things simpler. Maybe it's the next step.