I have a model like this:

[SitecoreType(TemplateId = "{BEF6BD47-1168-4EC9-9B03-A8C5F3420B73}", AutoMap = true)]
    public class PlayerCard
        public virtual string BackgroundColor { get; set; }
        public virtual string FontColor { get; set; }
        public virtual Link PlayerUrl { get; set; }
        public virtual Player Player { get; set; }

From the sitecore side, i have a Player created that works as the default value. How on the PlayerCard model can i load a default value for the Player using the item created on sitecore?

Update info:

The PlayerCard field contains a DropLink with a datasource that points to a list of Player's

  • How are the two linked? Is there a field on the player card? Or some convention you follow? It might be worth adding the relevant parts of the content tree and templates to the question. Commented Feb 9, 2017 at 18:36
  • I've updated the question with that information
    – Phoenix_uy
    Commented Feb 9, 2017 at 18:37
  • Hello, sorry, kids have been ill! As divamatrix suggests, your question isn't yet clear. Do you want a certain Player to always be the default for a PlayerCard? In which case a regular standard value should do the trick? Or do you want to set a default when creating a PlayerCard in code (or something like that?) Commented Feb 14, 2017 at 12:05
  • Hello! Yes, thats it! I want a default player allways a new player is created. I have a Player on sitecore datasource called Default and i want that Default Player to be asigned every time a new one is created
    – Phoenix_uy
    Commented Feb 14, 2017 at 12:16

3 Answers 3


EDIT: Glass should just map the property (make sure you've got the template id and auto mapping enabled for the Player model as well).

If you find it's still not mapping - try explicitly specifying the field name from your PlayerCard model:


public virtual Player Player  {get; set;}

As mentioned above - you should be able to use the Standard Values on the template for the PayerCard to do what you want with standard Sitecore functionality (so no coding required). This will work in Glass or any other ORM because they just hook off the standard functionality of the CMS.

Find your PlayerCard template within the Sitecore Content Editor (or using Rocks!):

Find the template

Go to the Builder Options Tab:

Builder Options

Click on Standard Values:

Standard Values

This will add an item under your template called __Standard Values - on this item - you set the Player field to point to your Default Player item in the content tree.

If your site is multilingual - you'll either need to have this field as Shared or if you want different values selected for each language - add a version for each language to the __Standard Values.

If you're using Unicorn or TDS for your content synchronisation - you'll need to make sure the Default item makes it to each environment with the same ID (so include it in content which gets deployed to all environments).

  • I know i can load that default value on standard values, but how do i load that value from the c# model?
    – Phoenix_uy
    Commented Feb 14, 2017 at 12:41
  • Glass should just map it :) I'll update my answer. Commented Feb 14, 2017 at 12:45

I don't know if this is for sure what you're asking, but knowing that under normal circumstances you could use Standard values to set a value, I'm assuming that you are using a view model that needs to have a standard value for a field not on the context item. That being said, this is what works for us (and we do use Glass but we also use TDS to generate models and there may be other settings that make this work for me) but I found that if I extend the TDS models.. it works to let me set default values that I can then set in my controller or leave to be set like the below example:

public partial class Article_Item
    public Banner_Advertisement TileAd { get; set; } = new SitecoreContext().GetItem<Banner_Advertisement>(Constants.ArticleTileGuid);

You can have Glass generate partial classes, and extend them to add custom properties and methods. For example you can have a new property to access the Player that will return the default if one is not set. This would give you more control over this behavior.

However if the default Player is always the same then using Standard Values would be sufficient, as Owen Niblock suggests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.