My first content type

Hi there! This is Mike, the guy who is working on the Oracle data provider of the PFS. But today I'm writing this post in a different role. It's time to use the system, it's time to create my first content type definition (CTD).

One of our clients needed a Reseller search module for his portal. The task is simple: the user selects a Town from a list and gets the Resellers located there. I'm sure there will be lots of posts about such things like creating a GUI with different methods in the future, but now I want to focus on the creation of the Reseller content type and the filtering.

The Reseller content has a few simple properties: name, address, phone, etc. These will be stored as ShortText properties, no suprise. The tricky thing is how to store the Town of the reseller. There are several solutions, depending on the amount of data and the functions the module needs.

1. the simpliest

<?xml version="1.0" encoding="utf-8"?>
<ContentType name="Reseller" handler="SenseNet.PortalEngine.Content.GenericContent" parentType="GenericContent" xmlns="">
    <Description>Reseller content type for a reseller search module</Description>
        <Field name="ResellerName" type="ShortText">
            <Description>Name of the reseller</Description>
        <Field name="Town" type="ShortText">
            <Description>Name of the town. Please be careful typing it.</Description>

        <Field name="Address" type="ShortText">
            <Description>Street, No</Description>
        <Field name="Phone" type="ShortText">

Of course we can store the Town in a string property. This is a good-enough solution, the town selector dropdown can be populated from it. This works very well, if there are not too many resellers and the administrator of the module doesn't make too many typos...However the filtering from these kind of contents is easy:

NodeQuery query = new NodeQuery();
query.Add(new TypeExpression(ActiveSchema.NodeTypes["Reseller"]));
query.Add(new StringExpression(ActiveSchema.PropertyTypes["Town"], StringOperator.Equal, townName));
return query.Execute();

2. the fool-proof
The problem with the solution above is that somebody will surely type "Assterdam" instead of "Amsterdam" so lets see a better one.

        <Field name="Town" type="Choice">
            <Description>Name of the town</Description>
                    <Option value='0'>Budapest</Option>
                    <Option value='1'>Debrecen</Option>
                    <Option value='2'>Szeged</Option>
                    <Option value='3'>Sopron</Option>

Here the administrator will have to choose from a list. When a new office opens in a new town, this list has to be updated in the CTD. This is not a big deal, but there is a solution that builds on the advanced capabilities of PFS.

3. the beautiful
Let's remove the Town property from the content type. This information will be stored in a folder structure in the PFS!

Instead of putting all the Resellers into one folder, lets create a separate folder for every Town. This boosts up the filling speed of the dropdown, because we don't need to iterate through the contents to collect the town names, only need to query for the folders. The reseller search is also faster, because we can use the Path property:

NodeQuery query = new NodeQuery();
query.Add(new TypeExpression(ActiveSchema.NodeTypes["Reseller"]));
query.Add(new StringExpression(StringAttribute.Path, StringOperator.StartsWith, townPath));
return query.Execute();

The good thing is that we can choose either of these solutions, the administration is very easy. I haven't written any content view actually because the generic view is absolutely enough for creating new Reseller contents. After uploading the content type definition, one can go to Portal Explorer and just click the New Reseller link in the Actions menu. The engine builds the form and we can fill the properties we defined in the content type definition above.

Comments (2) -

8/24/2009 6:12:08 AM #

Good example for reqular usage. Please let me have the code to fill the dropdown with the return values from the nodequery. I am comfort with contenttype creation and able to store the data. But I am just stuck to use the nodequery.

Thanks in advance


Sándor Kiss
9/7/2009 10:50:34 PM #

Hi Sudhakar,

Please post your development questions to the forum at


Pingbacks and trackbacks (1)+

Comments are closed

Welcome to the blog!

Sense/Net ECM is ever evolving. Community means the world to us so we want to keep you apprised on what’s happening on our side of the woods. Want to make us happy? Add a comment and tell us what you think!

Month List