Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt 353 posts 825 karma points
    Feb 12, 2020 @ 10:38
    Matt
    0

    Nested content not showing correctly

    Hi,

    I have an accordion as a nested template using partial view.

    I have made it an composition so I can reuse the code on other templates, which I thought worked fine...... now all of sudden it seems to have glitched and all of the accordions are the same? no matter what template/doc type I've added the composition to?

    It seems that it only gets the most recent accordion doc type.

    I'll try explain.

    So I have a department doc type and template, I've added the accordion composition to this and everything works fine.

    I have a general doc type and template, I've added the accordion composition to this and I publish and the content changes.... however it now shows the content on general template in the department template accordion? but if I then go back to my department accordion and publish that, it then goes back to how it was?

    But it only seems to happen on my published site not my development?

    Hope that makes sense......

    Thanks

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Feb 12, 2020 @ 13:49
    Nik
    101

    Hi Matt,

    So based on the discussion we've been having on slack, you are using Html.CachedPartial without setting a unique key per page.

    This means that which ever accordion first gets cached will be used when ever that partial is called again.

    Personally, unless your partial is behaviour really slowly (in which case there is probably another issue to be investigated), I wouldn't be using cached partial, instead I'd be using Html.Partial instead.

    So try changing:

    @Html.CachedPartial("Partials/Content/_Accordion", Model, 3600) to @Html.Partial("Partials/Content/_Accordion", Model)

    See how you get on with that.

    Nik

  • Matt 353 posts 825 karma points
    Feb 12, 2020 @ 13:59
    Matt
    1

    Thanks Nik, yeap I was using Html.CachedPartial

    All working now :)

Please Sign in or register to post replies

Write your reply to:

Draft