Try our conversational search powered by Generative AI!

Restriction of DisplayOptions tag not working

Vote:
 

Hi,

I am using multiple display options on my website and am trying to set up a block so that it only uses one of the display options. I have got the following display options set:

    public class SungardDisplayOptionsProvider : IDisplayOptionsProvider
    {
        public const string FullWidthTag = "full";
        public const string OneHundredTag = "100";
        public const string SeventyTag = "70";

        public void InitializeOptions(EPiServer.Web.DisplayOptions options)
        {
            options
            .Add("full", "/displayoptions/full", FullWidthTag, string.Empty, "epi-icon__layout--full")
            .Add("onehundred", "/displayoptions/onehundred", OneHundredTag, string.Empty, "epi-icon__layout--full")
            .Add("seventy", "/displayoptions/seventy", SeventyTag, string.Empty, "epi-icon__layout--full")
            .Add("fifty", "/displayoptions/fifty", ContentAreaDisplayOptions.Fifty, string.Empty, "epi-icon__layout--one-third")
            .Add("thirty", "/displayoptions/thirty", ContentAreaDisplayOptions.Thirty, string.Empty, "epi-icon__layout--one-third")
            .Add("twentyfive", "/displayoptions/twentyfive", ContentAreaDisplayOptions.TwentyFive, string.Empty, "epi-icon__layout--quarter");

        }
    }

In my TemplateCoordinator I do the following:

        public void Register(TemplateModelCollection viewTemplateModelRegistrator)
        {

            viewTemplateModelRegistrator.Add(typeof(CaseStudyFullWidthTextBlock), new TemplateModel
            {
                Tags = new[] { SungardDisplayOptionsProvider.FullWidthTag },
                AvailableWithoutTag = false,
                Path = BlockPath("CaseStudyFullWidthText.cshtml"),
                
            });

However, when I look at the CMS, I can see the following:

"The block 'Full width text block' cannot be displayed as /displayoptions/onehundred

The block 'Full width text block' cannot be displayed as /displayoptions/thirty

The block 'Full width text block' cannot be displayed as /displayoptions/seventy

The block 'Full width text block' cannot be displayed as /displayoptions/fifty

The block 'Full width text block' when displayed as /displayoptions/full

The 'CaseStudyFullWidthTextBlock' can not be displayed using the 'Full' display option

The block 'Full width text block' cannot be displayed as /displayoptions/twentyfive"

As you can see, it looks like it's trying to display the display option with the "full" tag as requested, but for some reason it can't. Even more strangely, If I set AvailableWithoutTag to true, all the views get rendered correctly for the block, including "full". This leads me to think there is a bug in episerver (I'm using version 9), but maybe i'm missing something?

Thanks for any help,

Sam

#186054
Dec 11, 2017 11:57
Vote:
 

It looks correct according to the SDK. I've not tested the code myself though.

Spontenous answer Episerver support usually gives is "try to upgrade to a later version".

In case you don't have time to upgrade to 11, at least try to upgrade to latest version within Episerver 9 (NuGet Package). Or copy your code into an Alloy Website running the latest version of Epi.

For comparison I generally compare my code with the examples in Alloy or as I just mentioned copy my code into Alloy.

#186312
Edited, Dec 16, 2017 16:20
Vote:
 

I wouldn't upgrade just yet.  i filed a bug with epi on the version 11 where it will add the first modeltype and 1 display option but omits the others.  The above code looks right though.  For some reason, worth a check, does it view exist in the right path?  BlockPath("xxxx.cshtml").  does the view exist?

#186317
Edited, Dec 17, 2017 17:31
Vote:
 

@Joshua - yes the view does exist in the right path, and it renders correctly in the preview when I set AvailableWithoutTag = true.

@Alf - I'll try the upgrade and that's a good idea about using Alloy to test this functionality to see if it works in the latest version.

#187073
Jan 11, 2018 10:27
Vote:
 

while I was writing these series of blog posts I came throught A LOT of stuff how that actually works, but it's a bit rusty now in my memory..

maybe you can find some answers there tho...

https://blog.tech-fellow.net/tag/look-inside/

#187089
Jan 11, 2018 15:27
Vote:
 

I can say this issue was fixed in a bug i filed.  I upgraded to the version it was fixed in and appears to be working now.  It would only register the first model and ignore the additional display options/tags. 

#187093
Jan 11, 2018 15:50
Vote:
 

The bug was filed here.  CMS-9294

#187094
Edited, Jan 11, 2018 15:52
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.