This project is read-only.

Page properties not saving in existing site.

Sep 2, 2008 at 2:03 AM
Edited Sep 2, 2008 at 2:05 AM
I am integrating N2CMS into an existing site.

I have gotten to the point to be able to create and move pages.

Now, when I add a attribute to a property and edit it in the UI, the changes do not get saved. The default Title property gets saved, but not any of my custom properties.

I have verified my .config is correct. I will post here for futher review. I am using MSSQL2005.

Also, if it matters, the page referenced in the template url is not a ContentPage(Of t). It is a custom page in my existing site.

                    <entry key="hibernate.connection.provider">NHibernate.Connection.DriverConnectionProvider</entry>
                    <entry key="hibernate.connection.connection_string_name">N2CMS</entry>
                    <entry key="hibernate.connection.use_second_level_cache">false</entry>
                    <entry key="hibernate.connection.hibernate.connection.driver_class">NHibernate.Driver.SqlClientDriver</entry>
                    <entry key="hibernate.dialect">NHibernate.Dialect.MsSql2005Dialect</entry>
        <!-- If you install a database from scrach you'll need to insert some required pages. This can be done by the web based installer located at http://yoursite/install/edit -->
        <host rootID="1" startPageID="2" />
        <!-- Other flavours: SqlServer2005, SqlServer2000, MySql, SqLite -->
        <database connectionStringName="SiteSqlServer" flavour="SqlServer2005" />
            <installer checkInstallationStatus="true" />
Sep 2, 2008 at 6:15 PM
I'm not sure but could it be that you're not storing the new value in the detail collection? See the documentation on editors.

It should make any difference in this case but you can remove the <castle> section and section handler if you want. There's a way to use the castle configuration but it's not enabled by default.
Sep 7, 2008 at 7:50 PM
Why wouldn't this save?

    <N2.Details.EditableCheckBox("ShowTitle", 1)> _
    Public Property ShowTitle() As Boolean
            Return Me.GetDetail("ShowTitle")
        End Get
        Set(ByVal value As Boolean)
            Me.SetDetail(Of Boolean)("ShowTitle", value, True)
        End Set
    End Property

It displays correctly when editing, but when I "publish" nothing happens. I checked the DB and there is no detail with the name of ShowTitle.
Sep 7, 2008 at 9:41 PM
The last parameter of the SetDetail method is used to avoid storing unnecessary values. If you set the property to true nothing will get stored. To make it work as as you expect you should do something like this:

            Return Iif((Me.GetDetail("ShowTitle") Is Null, True, Me.GetDetail("ShowTitle"))
        End Get

Or remove default value from SetDetail:

Me.SetDetail(Of Boolean)("ShowTitle", value)

I'm not sure wether you have the null coalescing operator in VB. It makes it a bit shorter. In C# it's something like this:

get{ return (bool)(GetDetail("ShowTitle") ?? true); }