TransWikia.com

Sitecore SxA Composite Layout not adding custom css and js

Sitecore Asked by Nadine Lendzian on August 23, 2021

We have created a custom Accordion Module. Therefore, we also changed the Accordion MVC Layout.cshtml for Accordion Items. But our custom theme doesn’t appear in the head nor does the js show up. What did we miss?

One Answer

I don't see any additional pieces of information from your side (as it was suggested in the comments) so I will write what I think you might be missing.

You wrote that you have a custom AccordionMvcLayout.cshtml. If you will take a look inside of that file, you will notice that on the top there is something like:

@{
    Layout = Sitecore.Configuration.Settings.GetSetting("XA.Feature.Composites.CompositeComponentLayoutPath", "Composite Component Layout.cshtml");
    ViewBag.Title = "Edit accordion item";
}

This view is using its own layout which is most cases (if not changed) is Composite Component Layout.cshtml. Go there and you will find the following lines in that file:

@{
    AssetLinks assetLinks = AssetLinksGenerator.GenerateLinks(new CompositeThemesProvider());
}

...

@foreach (string style in assetLinks.Styles)
{
    @Html.Raw(style)
}

...

@{
    foreach (string script in assetLinks.Scripts)
    {
        @Html.Raw(script)
    }
    ...
}

This code is responsible for rendering CSS and JS link. So double check if you custom layout have Layout = Sitecore.Configuration.Settings.GetSetting("XA.Feature.Composites.CompositeComponentLayoutPath", "Composite Component Layout.cshtml"); just like the original one.

Answered by Dawid Rutkowski on August 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP