Developer forum

Forum » Development » My custom item is not showing

My custom item is not showing

Sten Hougaard
Reply

Hi,

I thought I would try out creating my own item type following the guide here: http://developer.dynamicweb.com/documentation/for-developers/item-based-structure/getting-started.aspx

I am coding on a Mac using Xamarin Studio.

  1. I created a new empty ASP.NET solution 
  2. I added an empty C# class
  3. I pasted the code (see below) and build the DLL
  4. I uploaded the DLL to the bin folder on a test solution
  5. I opened items in management center, no "BlogPost" item
  6. I tried to press "Refresh", no "BlogPost" item

What am I doing wrong? My DLL is attached.


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

E: sho@1stweb.dk
M: 29850818
A: København/Aarhus . W: www.1stweb.dk
@: netsi1964

 

using System;
using Dynamicweb.Content.Items;

namespace sho
{
    public class BlogPost : ItemEntry
    {
        public string Heading { get; set; }
    }

}

 


Replies

 
Martin Nielsen
Reply

Hi Steen,

Add this to your class and it should work:

[Name("Blog entry")]
public class BlogPost : ItemEntry
{
    public string Heading { get; set; }
}

It's missing from the documentation, but it neccesary none the less.

 

// Martin

 
Sten Hougaard
Reply

Thanks Martin,

However, since I am building from scratch (using no Dynamicweb templates) I get a compiler error:

"The type or namespace name 'Name' could not be found. Are you missing an assembly reference?"

What do I need to reference to be able to add that "method attribute"? ( [Name("Blog entry")])


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

E: sho@1stweb.dk
M: 29850818
A: København/Aarhus . W: www.1stweb.dk
@: netsi1964

 
Sten Hougaard
Reply

My clever colleague Thomas Larsen helped me on that one! Thanks Thomas.

using System;
using Dynamicweb.Content.Items;
using Dynamicweb;
using Dynamicweb.Extensibility;

namespace sho
{
    [Dynamicweb.Content.Items.Annotations.Name("Blog entry")]
    public class BlogPost : ItemEntry
    {

        public string Heading { get; set; }
    }

}

 

Now I have my first .NET based item! :-)

Great stuff - please update your documentation, Dynamicweb!


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

E: sho@1stweb.dk
M: 29850818
A: København/Aarhus . W: www.1stweb.dk
@: netsi1964

 
Morten Bengtson
Reply

Instead of the Name attribute, you could also use the Item attribute, which allows you to specify both name and description...

[Item("The Item", "Some item description"), TitleField("Header")]
public class MyItem : ItemEntry
{
    [Text("The header", Description = "This is the header")]
    public string Header { get; set; }
}

 

You must be logged in to post in the forum