0

In a .cshtml View I've got:

<a href="@this.HomePage.BulkPurchasesPage.Url">

I haven't been able to locate this so far. I don't see it on neither the Template __StandardValues nor on the Content data fields. So it's probably in one the the Templates above, in the inheritance?

Visual Studio an F12 "Go to definition" :

  /// <summary>
    /// The Bulk Purchases Page field.
    /// <para></para>
    /// <para>Field Type: Droptree</para>       
    /// <para>Field ID: e4e701fc-1f03-4898-8a24-0acbdccb1021</para>
    /// <para>Custom Data: type=PageBase</para>
    /// </summary>
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Team Development for Sitecore - GlassItem.tt", "1.0")]
    [SitecoreField("Bulk Purchases Page")]
    public virtual PageBase BulkPurchasesPage  {get; set;}

    /// <summary>
    /// The <see cref="Sitecore.Data.ID"/> of the 'Bulk Purchases Page' field.
    /// </summary>        
    public static ID BulkPurchasesPageFieldId = new ID("e4e701fc-1f03-4898-8a24-0acbdccb1021");

Which I don't know how to leverage. There must be another way, either from the Sitecore Tree, or from Visual Studio F12 to track this HomePage.BulkPurchasesPage.Url field back.

Thank you

2
  • When you search for the field id in the content editor, do you get a result? Feb 7 '18 at 20:14
  • Thank you Hishaam, yes I was able to progress from this point of entry. I'm preparing a summary of my findings. And thank you Mark for the editing! Feb 8 '18 at 20:40
1

The code you've included above suggests that your project is using Glass Mapper. Glass is an ORM tool for Sitecore that will take items from your database and map them to C# object for you. It's kind of like Entity Framework, but for Sitecore data.

Glass can map to objects created from classes you define, or it can dynamically build objects that implement interfaces you define.

So somewhere in your database you have an item that your code has loaded using Glass. As it's gone through your item, Glass has looked at the Field "Bulk Purchases Page" as part of its mapping process. It's found a GUID there I expect. The C# property you show above has an attribute SitecoreField("Bulk Purchases Page") which tells Glass "map the value of the database field with this name into the value of this property". The property is defined as having the .Net type "PageBase" - which Glass sees as "another class which can represent an item". Hence it loads the item the GUID points at, and repeats the mapping process to put the target item into an instance of PageBase.

So the property "URL" is most likely defined on the PageBase class, or something it inherits from. This property will probably have an attribute on it (SitecoreInfo(SitecoreInfoType.Url)) which tells Glass to use Sitecore's LinkManager to work out the correct URL for the item being mapped, and then set the property's value to that.

There's more detail about using Glass on the tool's website: http://glass.lu/Mapper

2
  • Thorough explanation, thank you. Yes we do have Glass Mapper and I haven't had a chance to see what it does yet. Actually I thought it was part of the Sitecore base distribution. I'll need some time to digest, I've opened your link and started to read. Feb 8 '18 at 20:49
  • That's fine. I can try and add more detail to anything that doesn't make sense if it would help you.
    – JermDavis
    Feb 9 '18 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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