tags:

views:

360

answers:

2

I'm currently playing around with a CMS idea I've got. It's based on a MonoRail, NHibernate stack. I know there are already a million CMS solutions out there. This is more for my benefit for trying some new stuff out.

Anyway, the admin side of things is going well with a plugin architecture in full flow, however I've hit a bit of a road block with the front end template management side of things.

What I'm wanting to do is allow developers to write their own custom tags e.g.

<cms:news>
    <h1><cms:news:title /></h1>
    <p><cms:news:date /></p>
    <cms:news:story />
</cms:news>

I believe this will give developers a great deal of flexibility.

The part I'm struggling with is the parsing of these tags. I could use reflection, however I'm worried that this may be quite intensive for every page. Has anyone else done something like this, that has a better solution?

Sorry for the lack of info guys. Here is a bit more info for you.

The above code would site in a "page" in the CMS. The complete page markup would simply be a DB record.

Once the parser hits there tags it would then need to process them to convert them to content. In the example above the parser would hit the cms:news tag and make a call to a function like this

public void news()
{
     // Get all of the news articles from the database
}

The cms:news:title (or cms:news.title) tag would call a function like this

public string newstitle()
{
    // Return the news title for the current news element we are rendering
}

Hope this makes more sense now

Thanks

John

A: 

The tags you're considering to use are not valid XML : you can't have multiple colons in an element name (only one to separate the namespace from the local name)

Consider this instead :

<cms:news>
    <h1><cms:news.title /></h1>
    <p><cms:news.date /></p>
    <cms:news.story />
</cms:news>

To parse this XML, there are a number of options available to you :

  • XmlReader
  • XmlDocument
  • XDocument (Linq to XML)

I don't think XML serialization is an option if the tags are customizable...

Anyway, I'm not sure what you're trying to achieve exactly... What would you do with those tags ? Could you be more specific in your question ?

Thomas Levesque
downvoter, care to give a reason ?
Thomas Levesque
+1  A: 

I think I've been looking at this all wrong.

I could basically do this my using something like the Spark View Engine's InMemoryViewFolder and using ViewComponents for the custom tags.

John Polling