MetaMaster 2008 - finally released!

MetaMaster 2008 - finally released!

Posted on July 03, 2008 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

 

Nice title, ehh?

Since everyone seems to be releasing something these days, I thought I’d give it a try on my blog as well. From now on, I’ll be branding all the code samples.  For the time being all the samples will be released under RandomSFCode label (until I come with something more along the web 2.0 lines) and the first control is MetaMaster 2008 (even though it sounds like it could help you lose 20 lbs in 10 days, it won’t. Nevertheless, talk to your physician about it. He may like it.)

So, what is MetaMaster 2008?

MetaMaster 2008 is a control that you can use in conjunction with any ContentView based control (ContentView, BlogPosts, NewsView and EventsView). What MetaMaster 2008 allows you to do is to easily map the values of meta-fields to any property of any control inside of a template. Take a look at the following example:

<cc1:MetaMaster ID="MetaMaster1" runat="server">  
    <Mappings> 
        <cc1:MetaMapping MetaKey="Title" TargetControlId="testLabel"                               TargetProperty="Text" /> 
        <cc1:MetaMapping MetaKey="Author_Picture" TargetControlId="testImage"     
                         TargetProperty="ImageUrl" /> 
        <cc1:MetaMapping MetaKey="Author_Picture" TargetControlId="testImage"    
                         TargetProperty="Tooltip" /> 
    </Mappings> 
</cc1:MetaMaster> 
 

 

All you need to do is place this control in any of the ContentView templates (for now this control will work only in a template for SingleItem mode – for example, for NewsView you can add this control to ListPageDetails.ascx).

So, once you place the MetaMaster control in the template, you can add any number of mappings to it. Each mapping consists of three properties that you need to set:

MetaKey
– the value of which meta-field should be mapped to control’s property
TargetControlId – the id of the control whose property you want to map to meta-field value
TargetProperty – finally, the value of which property you want to set to the value of meta-field

The way standard ContentView control works is following – it reads all the metakeys, tries to find the controls with same ids and then sets the text property of the control to the value of the meta-field. Sometimes, however, you may need two labels to display the value of same meta-field. On other occasions, you may have the URL as a value of meta-field and you want this value to be in ImageUrl or NavigateUrl property, not just text. The common solution to this problem is to overwrite the ContentView control and make your own implementation – and judging by your feedback – you don’t exactly enjoy this. So – that’s how MetaMaster 2008 was born (the slow Thursday in office helped as well).

How to install MetaMaster 2008?

The control comes with full source, so you can modify it or fix it, if needed. Basically, all you need to do is compile the .dll with the references to the dependent projects from your own website (or you can use my .dll if you are running the latest hotfix).

YOU CAN DOWNLOAD THE WHOLE PROJECT FROM HERE.

1. Then take that .dll and copy it to the bin folder of your website.

DO NOT UPLOAD THIS CONTROL THROUGH SITEFINITY PAGE EDITOR.

2. Open the template (in Visual Studio) that represents a template for single item mode of any ContentView control. Here are some examples:

~/Sitefinity/ControlTemplates/News/Modes/ListPageDetails.ascx       ~/Sitefinity/ControlTemplates/Events/Modes/ListPageDetail.ascx         ~/Sitefinity/ControlTemplates/Generic_Content/ContentViewSingleItem.ascx

3. Register the assembly for the control, by adding this line at the top of the template:

<%@ Register Assembly="RandomSFCode.MetaMaster2008"                   
             Namespace="RandomSFCode.MetaMaster2008" 
             TagPrefix="cc1" %> 
 

4. Add the MetaMaster control to the template and start mapping:

<cc1:MetaMaster ID="MetaMaster1" runat="server">  
    <Mappings> 
        <cc1:MetaMapping MetaKey="Title" TargetControlId="testLabel"                               TargetProperty="Text" /> 
        <cc1:MetaMapping MetaKey="Author_Picture" TargetControlId="testImage"    
                         TargetProperty="ImageUrl" /> 
        <cc1:MetaMapping MetaKey="Author_Picture" TargetControlId="testImage"     
                         TargetProperty="Tooltip" /> 
    </Mappings> 
</cc1:MetaMaster> 
 

 

YOU CAN DOWNLOAD THE WHOLE PROJECT FROM HERE.

I’ve done some superficially testing and its working. If you ran in problems leave a comment and I’ll try to address them in timely manner.

   
progress-logo

The Progress Team

View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments

Comments are disabled in preview mode.
Topics

Sitefinity Training and Certification Now Available.

Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.

Learn More
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

Loading animation