Giter Site home page Giter Site logo

Comments (10)

valdisiljuconoks avatar valdisiljuconoks commented on June 26, 2024

Can you check in IoC (StructureMap) which Content area renderer is registered? Easily visible via Episerver Developer Tools

from optimizely-advanced-contentarea.

yophen avatar yophen commented on June 26, 2024

Thanks for the reply!

When I try to install the DeveloperTools in the Episerver project using nuget the project builds ok but I get an error saying that the file could not be loaded when loading the website. Using version 3.5. Tried using Alloy with Episerver 11.12 as well.

"Could not load file or assembly 'EPiServer.DeveloperTools' or one of its dependencies. The system cannot find the file specified."

Regarding the EPiBootstrapArea, it seems to be the correct content area renderer registered since other EPiBootstrapArea functionality is working.

from optimizely-advanced-contentarea.

yophen avatar yophen commented on June 26, 2024

I tried to install EPiBootstrapArea using an empty Alloy website and there it seems to be working, at least in the basic configuration. I'll try and troubleshoot if there's any EPiBootstrapArea configuration that might interfere.

from optimizely-advanced-contentarea.

valdisiljuconoks avatar valdisiljuconoks commented on June 26, 2024

Ok that's weird for developertools. I'll take a look later.

If it's working correctly in alloy - might be some config in your project.
Do you advanced-cms content review plugin? if so - you might need to jump to latest there as well.

from optimizely-advanced-contentarea.

yophen avatar yophen commented on June 26, 2024

No, not using the advanced-cms content review plugin but thinking about it. Thanks for the tip.

The thing that seems to happen in the BlockIndex htmlhelper is that htmlHelper.ViewData does not contain any keys so looking for the "BootstrapContentArea__BlockIndex" will return -1.

Regarding dependency injection, I take it that BootstrapAwareContentAreaRenderer sets up it's own DI in the SetupBootstrapRenderer class, so no manual DI configuration is needed, is this correct?

from optimizely-advanced-contentarea.

valdisiljuconoks avatar valdisiljuconoks commented on June 26, 2024

Yes, that's correct, no manual DI is needed.

from optimizely-advanced-contentarea.

birgitzprinz avatar birgitzprinz commented on June 26, 2024

For me changing the code like this make it works again:

public static DisplayOption GetDisplayOption(this HtmlHelper htmlHelper, BlockData block)
{
    if(htmlHelper == null)
        throw new ArgumentNullException(nameof(htmlHelper));

    if(block == null)
        throw new ArgumentNullException(nameof(block));

    return htmlHelper.ViewContext.ParentActionViewContext.ViewData.ContainsKey(Constants.CurrentDisplayOptionKey)
               ? htmlHelper.ViewContext.ParentActionViewContext.ViewData[Constants.CurrentDisplayOptionKey] as DisplayOption
               : null;
}       

I guess it's because in our project, we're using dedicate block controller instead of just registering a block with a partial view.

from optimizely-advanced-contentarea.

valdisiljuconoks avatar valdisiljuconoks commented on June 26, 2024

v5.3 is on the way to the feed

from optimizely-advanced-contentarea.

jonascarlbaum avatar jonascarlbaum commented on June 26, 2024

If others have similar issues, it could be custom block controllers messing this up.
I ended up reading the value in the controller and extending the BlockViewModel.
Maybe there is some way to pass ViewData from ParentActionViewContext on to make the Html.GetIndex()-helper work, but didn't investigate it any further.

[TemplateDescriptor(Default = true, Inherited = true)]
public class DefaultBlockController : BlockController<BaseBlockData>
{
    public override ActionResult Index(BaseBlockData currentBlock)
    {
        var model = CreateModel(currentBlock);
        var blockName = currentBlock.GetOriginalType().Name;            
        model.BlockIndex = int.Parse(ControllerContext.ParentActionViewContext.ViewData["BootstrapContentArea__BlockIndex"]?.ToString() ?? "-1");
        return PartialView(string.Format("~/Features/Blocks/{0}/{1}.cshtml", blockName, blockName), model);
    }

    private static IBlockViewModel<BlockData> CreateModel(BlockData currentBlock)
    {
        var type = typeof(BlockViewModel<>).MakeGenericType(currentBlock.GetOriginalType());
        return Activator.CreateInstance(type, currentBlock) as IBlockViewModel<BlockData>;
    }
}

from optimizely-advanced-contentarea.

valdisiljuconoks avatar valdisiljuconoks commented on June 26, 2024

from optimizely-advanced-contentarea.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.