Navigatie

Contact

Send mail to the author(s) E-mail

View Richard Soeteman's profile on LinkedIn

RSS 2.0 | Atom 1.0 | CDF

Archief

Categorieën

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Sign In

Zoeken

# Monday, 04 January 2010
Monday, 04 January 2010 21:37:53 (GMT Standard Time, UTC+00:00) ( Umbraco )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

This forum post  triggered me to share some code that I had. A while back I was building a site which  let the customers define their own custom overviews One requirement was that users could define the sort by property . To do this you can use the property picker but it wasn’t friendly enough for my case so I ended up building a custom macro parameter type.

To start you need to create a new class library and add references to the following assemblies:

  • Businesslogic
  • Cms
  • Interfaces
  • Umbraco
  • System.web

In the example below I’ve created a class that inherits from dropdownlist. This was the easiest way since I needed a dropdownlist and didn’t want to play with the control tree, Now more important is that this class inherits from the IMacroGuiRendering Interface.  This add two properties ShowCaption, to show the caption on the parameters tab and more important value which holds the selected value . 

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Text;
   4:  using System.Web.UI.WebControls;
   5:  using umbraco.interfaces;
   6:   
   7:  namespace MacroRenderDemo
   8:  {
   9:      public class OrderBy : DropDownList, IMacroGuiRendering
  10:      {
  11:          protected override void OnLoad(EventArgs e)
  12:          {
  13:              base.OnLoad(e);
  14:              if (this.Items.Count == 0)
  15:              {
  16:                  this.Items.Add(new ListItem("Title", "nodeName"));
  17:                  this.Items.Add(new ListItem("Date", "createDate"));
  18:              }
  19:          }
  20:   
  21:          #region IMacroGuiRendering Members
  22:   
  23:          public bool ShowCaption
  24:          {
  25:              get { return true; }
  26:          }
  27:   
  28:          public string Value
  29:          {
  30:              get
  31:              {
  32:                  return this.SelectedValue;
  33:              }
  34:              set
  35:              {
  36:                  this.SelectedValue = value;
  37:              }
  38:          }
  39:   
  40:          #endregion
  41:      }
  42:  }

When you build the project and add the binary into the bin folder of your Umbraco site you still can’t select the new type from the parameter type list. First we need to register the class  in the database. Below you’ll see the database table that holds all the Macro property types.

dbrecords 

It is important that you add the Assemblyname  including the namespace to the macroPropertyTypeRenderAssembly column and add the name of your class to the  macroPropertyTypeRenderAssembly column .

Now we can use the parameter in our macro’s

parameters

and off course we can now use the new parameter in our template when we select the macro

InsertMacro

Another example how flexible Umbraco is. If a requirement isn’t available out of the box, usuallyall it takes is to implement an interface and write a few lines of code.

Comments [4] | | # 
# Saturday, 02 January 2010
Saturday, 02 January 2010 09:34:32 (GMT Standard Time, UTC+00:00) ( Umbraco )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

Let’s start with wishing you all the best for 2010. 2009 was an insane year for me, I had given myself one year  being successful in business running my own Umbraco  projects instead of being a .net contractor. That turned out great, I’ve got a lot of new customers, have build a few great sites for my customers  and did a few Umbraco consulting jobs. So now it’s time to make plans for 2010.  First thing is that I’m moving to a real office instead of working from home. I’m really excited about this because I’m moving to an office building with lots of small companies, I think that’s really inspiring.

When I’ve started investigating Umbraco back in 2008 we had a small amount of companies in the Netherlands (mostly freelancers) that where building websites based on Umbraco. Nowadays I see new companies that build Umbraco websites every week, not only small shops but also really big agencies. For this year my focus will be on helping companies (worldwide) being successful implementing Umbraco sites for their clients by offering consultancy services and custom package development  instead of building sites from front to end.

As you might know I’m also working for a long time on UmbImport PRO. My plan was to release this package last year. It’s the top prio on my todolist for Q1 this year. Also another package will see the light this year, UmbLinkChecker. As the name says this will be a package that checks every link in your published site, not only in content but also hard coded links in your templates etc., I will build a free and Pro version. Since Umbraco has more than 75000 active installs I think it’s profitable to build commercial packages for Umbraco and we will see more and more commercial packages from different vendors. Hope the Umbraco store will be back up in 2010 and filled with great products.

The last year I couldn’t find enough time to blog or write WIKI’s and helping the community with their problems on the forum. I’m hoping this year that will change, since I’ve got a lot of info that I’d like to share.

Have a great 2010!

Comments [0] | | #