1

I cloned Search Results Component and when I edit any thing in cshtml inside else scope

<div @Html.Sxa().Component(Model.Rendering.RenderingCssClass ?? "search-results testShaimaa", Model.Attributes) data-class-variant="@variantClass" data-properties='@Model.JsonDataProperties'>

@if (WebUtil.GetQueryString(Sitecore.XA.Feature.Search.Constants.CreativeExchangeExport) != "true")
{
    <div class="component-content">
        @Model.MessageIsEmpty
        <div class="no-results" style="display: @Model.StyleDisplay">
            @Html.Sxa().Field("ResultsNotFoundText", Model.DataSourceItem, !Model.IsControlEditable)
            @Html.Sxa().Field("Text", Model.Item, !Model.IsControlEditable)
        </div>
        <div class="progress"></div>
    </div>
}
else
{
<div>ssss</div>
<div>ssss</div>
    <ul class="search-result-list testShaimaa">
        <li>

            @foreach (BaseVariantField variantField in Model.VariantFields)
            {
                @Html.RenderingVariants().RenderVariant(variantField, Model.PageItem, true, Model)

            }
        </li>
    </ul>

}

does not reflect in the page but when I edit before If it reflects in the page so I am sure that this the correct cshtml file for this cloned search result rendering, I think that caching but I changed variant and cloned another one.

Any Ideas Why this happens and how my changes reflects in the page ??

2 Answers 2

1

Your "if" statement mentions Creative Exchange:

if (WebUtil.GetQueryString(Sitecore.XA.Feature.Search.Constants.CreativeExchangeExport) != "true")

This tells me that the else part will be executed when the Creative Exchange parameter is in the querystring. That is why you will never see that part in the actual website - you'll always get the first (if) part.

More information on Creative Exchange on the official docs: https://doc.sitecore.com/developers/sxa/18/sitecore-experience-accelerator/en/working-with-creative-exchange.html

1
  • So how can the Html inside the else part be modified?
    – Pranay
    Mar 7, 2022 at 9:40
0

The class "search-results testShaimaa" you are using in this line :

<div @Html.Sxa().Component(Model.Rendering.RenderingCssClass ?? "search-results testShaimaa", Model.Attributes) data-class-variant="@variantClass" data-properties='@Model.JsonDataProperties'>

is the same Rendering css class field added to your cloned view rendering? also cross the the path for the view file in the field: Rendering view path - e.g. ~/Views/Title/Title.cshtml [shared]: Under Experience Accelerator section

Your Answer

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

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