I need to resolve the wildcard item (*) to a product repository which has products and show the presentation details of the (*) item.

Now i am using the following structure

  • Products
    • Product Collection 1
      • * (presentation details)
    • Product Collection 2
      • *  (presentation details)
    • Product Collection 3
      • *  (presentation details)


  • Global Repository
    • Products
      • Product 1 (no  presentation details)
      • Product 2 (no  presentation details)
      • Product 3 (no  presentation details)

I am using Adam Conn's wildcard module and have setup the routes for routing the (*) item to the repository item. Also have created a custom wild card item resolver (after the item resolver) to get the wildcard item as context item, which is resolving as expected.

But the issue is the resolved item does not have presentation details and I need to use that item as a datasource for the (*) item.

I have tried to use this from blog : http://hdaoud.blogspot.com/2017/05/sitecore-resolve-wildcard-item-and-fix.html

and also found some details about the same in https://community.sitecore.net/developers/f/8/t/3655

Please help me on to solve this issue.



If you have your custom WildcardItemResolver processor, set the wildcard item in HttpContext.Current.Items before replacing it with your product item, e.g.:

class WildcardItemResolver : HttpRequestProcessor
    public override void Process(HttpRequestArgs args)
        // your code here
        // before you set Sitecore.Context.Item to the product item, save wildcard item reference
        HttpContext.Current.Items["MyWildcardItem"] = Sitecore.Context.Item; 
        Sitecore.Context.Item = myProductItem;

Now create GetFromWildcardItemLayoutField processor which will be executed before the default GetFromLayoutField and which will read the presentation details from the wildcard item instead of reading from the product item:

class GetFromWildcardItemLayoutField : GetFromLayoutField
    protected override XElement GetFromField(GetXmlBasedLayoutDefinitionArgs args)
        var myWildcardItem = HttpContext.Current.Items["MyWildcardItem"] as Item;

        if (myWildcardItem != null)
            return GetFromField(myWildcardItem);

        return null;

and register the processor before the default GetFromLayoutField:

  <processor type="Your.Assembly.Namespace.GetFromWildcardItemLayoutField, Your.Assembly"
     patch:before="processor[@type='Sitecore.Mvc.Pipelines.Response.GetXmlBasedLayoutDefinition.GetFromLayoutField, Sitecore.Mvc']" />
| improve this answer | |

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.