This project is read-only.

Suggestion: Databound ContentItems

Topics: Developer Forum, Project Management Forum, User Forum
Oct 28, 2008 at 11:02 PM
I noticed in the Templates solution, you created a ContentItem for each wiki item, user, etc.

This is great to have a single template for multiple database items.

But what if you have an existing api? What if the datasource is from something other than the N2 website?

It would be great to have a new page class, such as DataBoundContentPage(Of t).

I have created a technique to do this that requires implementing your own IUrlParser and match urls to regular expressions, and if it matches, return that ContentItem for the url. (Product-Name_1 & Product-Name2-2 all returns ProductPage).

I hate writing code that is hardcodes the content model into it and as I can see by your absolutley wonderful program, you are very good at creating architectures for this scenario.

So just a suggestion for next release, maybe you can see what you can do for us? ;)
Nov 8, 2008 at 10:06 PM
Hi, I'd like to understand this scenario a bit better. I just changed the way the wiki templates are resolved.

Are you generating content items out of an external table and presenting them as items in n2?
Nov 9, 2008 at 4:13 AM
"Are you generating content items out of an external table and presenting them as items in n2?"

Not exactly "generating". I have one contentitem (page) called product. you can visit this page by visiting What I did was in the url parser, look for a pattern "Product-Name_1" using regular expressions and return that same product.aspx. Then will actually be behind the scenes be mapped to I created parts for this page like "Add to Cart" and "Product List", etc.

For the ProductContentItem, I have a property "CurrentProduct" which represents the current product. It parsed the ID out of the url and retrieves it from an external database.

Nov 9, 2008 at 4:14 PM
If you turned /Product-Book_2.aspx into /Product/Book_2.aspx there's some new support. I'll think about the regular-expression use case. Do you have an idea how it could look? From an usage point of view.
Nov 9, 2008 at 5:38 PM
The current project I am working on, I allready hard coding everything. But now that I'm done and walked through every qwark that showed up, I will be creating a new class.

I was thinking about a class titled DataboundContentItem. A must over-ride property "RegularExpression". Override the Equals(string name) to determine if the name matches the regular expression.

Also, make this class generic so the T can be the type of the databound item, in my case Product.

For the next part, I have to possible ways of doing things. One way is nice but may bring problems to contorls. Before I begin though, the code where you load the part's usercontrol, is it a component? If that is the case, I would like to determine if the item is a databound item, and if it is AND we are in edit/preview/drag mode, replace the control url with a generic placeholder user control that maybe just shows the title of the abstractitem. The reason for this is because parts that are built on top of the databound my depend on the CurrentDataBoundItem and that item may be null when simply creating a new instance of this contentitem inside N2.

A quick question. Is there a way to define a regular expression that we can also use to extract things like the ID or something along that line? I would like to be able to store the url format in some config.