Tuesday, June 30, 2009

Umbraco Member CanEdit == False?

How do you deal with this situation? In the members section of Umbraco there is a property called MemberCanEdit which then allows in theory a member to edit or not edit the property.

Each property renders a System.Web.UI.Control from the IDataEdtior interface. With System.Web.UI.Control there is no property which can disable the control as opposed to the System.Web.UI.WebControls.WebControl which you are normally use to which has the enabled property.

For controls which are infact webcontrols you can cast the control to a System.Web.UI.WebControl.WebControl control and you will then get the benefit of an enabled property. Not sure what do to do if this fails...Show a label instead?



if (mt.MemberCanEdit(pt))
{
_dataFields.Add(dt);
}
else
{
try
{
((System.Web.UI.WebControls.WebControl)dt.DataEditor.Editor).Enabled = false;
}
catch
{

}
}

Monday, June 29, 2009

Member Action Handlers

Sometimes you need do stuff with members once you've created, delete, changed something. The code below adds two new action handlers 1 when a member is created and one when a members is saved. In version 4 of Umbraco create a new class project and do something like so:




   1:   public class MemberAction : ApplicationBase

   2:      {

   3:   

   4:          public MemberAction() {

   5:          Member.New += new Member.NewEventHandler(Member_BeforeSave);

   6:          Member.AfterSave += new Member.SaveEventHandler(Member_Save);

   7:          }

   8:   

   9:          void Member_BeforeSave(Member sender, NewEventArgs e)

  10:          {

  11:              //do something here

  12:          }

  13:          

  14:          void Member_Save(Member sender, SaveEventArgs e)

  15:           {

  16:              //do something here

  17:             

  18:              //get new member details

  19:               Member m = Member.GetMemberFromEmail(sender.Email);

  20:           }

  21:          

  22:      }

Tuesday, June 23, 2009

Gravatar Package for Umbraco

To learn more about Gravatar please visit http://en.gravatar.com/.

This is a very simple asp.net C# user control which will spit out a gravatar image. All gravatar options are included in this package.

You can choose to use a default image if no email is fond (silhouette, blank image etc) or use a generated one from Gravatar (identicon, monsterid, wavatar)

Happy to fix any issues you encounter or download the source and alter.

Thanks,
Matthew

DOWNLOAD SOURCE DOWNLOAD PACKAGE

Monday, June 22, 2009

Umbraco Tip #3

Save time by using post build events

Whenever I am building Umbraco user controls there is a of development time and one way to save some time is to use Visual Studio post build events, this saves time by not having to manually copy over the .dll and ascx files from from user control solution to your umbraco solution.

To Add post build events right mouse click on your project > properties > build events. Click on the Edit- Post-build event button.

Here are what my post build events look like. Remeber if your path inludes spaces you will need to surround you copy statments with ""

copy "$(TargetPath)" "E:\Projects\Test Projects\ApplicationForm\bin"
copy "$(SolutionDir)\ApplicationFormUserControls\*.ascx" "$(SolutionDir)\UserControls\ApplicationFormControls\"

Umbraco Tip #2

How to redirect to a nodeid.

Response.Redirect(umbraco.library.NiceUrl());

Example: - Redirect to the same page currently on.

Response.Redirect(umbraco.library.NiceUrl( umbraco.presentation.nodeFactory.Node.GetCurrent().Id));

Umbraco Tip #1

Over the next few weeks I'll be posting a daily tips about the Umbraco library and how to use them in your code behind when building Umbraco user controls. This tips are targeted towards beginners of Umbraco user controls.

Tip #1

How to get the current nodeid from code behind?

umbraco.presentation.nodeFactory.Node.GetCurrent().Id

Sunday, June 14, 2009

nopCommerce vs dashCommerce?

Anyone have any thoughts? I have been a big fan of dashCommerce in the past and I have many websites still running dashCommerce with a lot of success, however recently I've become less favourable towards dashCommerce and I'm not exactly sure why. When dashCommerce use to be the CommerceStarterKit there use to be a huge community/help each other out feel to the software and to the community. However dashComemrce now doesn't seem quite this way and with the introduction of having to pay for certain provider I would suggest this has gone a long to making the software seem less from open source. I've just started a new e-commerce store (still in development) and I had a search around for other open source asp.net shopping carts. I stumbled upon nopCommerce (how did I not know about this before!) and all I can say is WOW so far, the architecture seems very similar to dashCommerce there are plenty of free providers and most importantly there seems to be a great feel to the nopCommerce community. I look forward to working with this software and will let you know how it goes. If you have some thoughts on dashCommerce or nopCommerce then I would love to hear them.