0

I have created a rendering parameter.

It is bound to a rendering called ProductRendering in its parameters template. This rendering is a controller rendering and points to a razor file called product.cshtml.

But I have another razor file called cart.cshtml and I need the above rendering parameter in this razor.

I am unable to get it in this razor.

2 Answers 2

0

I am not sure what code you are using to achieve this but it depends on the architecture of your project that how you pass the parameters. So I would suggest here two ways to do this.

  1. Use cart.cshtml as a partial view and call this in your product.cshtml and pass the model in the partial view to get all the values you need.
  2. Another way you can try is by creating this rendering as Compatible Rendering. A Compatible Rendering is simply a component that can be replaced with another component providing both use the same datasource type (or no datasource at all); e.g. use the same type of data.

You can follow this article to know about how to setup.

https://mattneil.co.uk/2017/01/17/compatible-renderings-in-sitecore/

Hope this helps.

0

I am agree with @Sumit, if you follow #1 from his comment, on productcontroller you can get the rendering parameter

  string TitleCss = string.Empty, DescriptionCss = string.Empty;

        var rc = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull;
        if (rc != null)
        {
            var parms = rc.Rendering.Parameters;
            TitleCss = parms["TitleCss"];
            DescriptionCss = parms["DescriptionCss"];
        }

on cart.cshtml you can pass rendering parameters properties by viewmodel.

I hope it will help.

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.