SaaS CMS has officially launched! Learn more now.

New blocks show message "The 'block' can not be displayed"

Vote:
 

I'm learning EPiServer 7.5, and have created a couple of blocks for an image slider.  We're doing this in MVC.  I've added a ContentArea to a view, and am able to successfully drag blocks to the view and also to use the "create a new block" link that appears in the content area.  However, after adding one or more blocks, the area where each block would appear displays a message like the following:

"The 'SlideBlock' can not be displayed"

This message persists whether I publish the changes or not.  Upon selecting the properties icon for any of these blocks, I see the following menu options:

  • Edit
  • Personalize
  • Move Up
  • Move Down
  • Remove

But I don't see the "Display As" menu option with it's submenu of choices.  That may be where my problem stems.

This is my SlideBlock view.

@using EPiServer.Core
@using EPiServer.Web.Mvc.Html
 
@model EPiServerExercise.Models.Blocks.SlideBlock
 
<>div class="psSlide @Html.PropertyFor(m => m.CssClass)">
 
    @if (!String.IsNullOrEmpty(Model.ImageLinkUrl))
    {
        <>a href="@Html.PropertyFor(m => m.ImageLinkUrl)">
    }
    @if (!String.IsNullOrEmpty(Model.ImageSrc))
    {
        <>img src="@Html.PropertyFor(m => m.ImageSrc)"
             alt="@Html.PropertyFor(m => m.ImageAlt)"
             title="@Html.PropertyFor(m => m.ImageTitle)"
             border="0" />
    }
    @if (!String.IsNullOrEmpty(Model.ImageLinkUrl))
    {
        a>
    }
    
div>

And this is my SlideBlock model.

using System;
using System.ComponentModel.DataAnnotations;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
 
namespace EPiServerExercise.Models.Blocks
{
    [ContentType(
        DisplayName = "Slide Block",
        GUID = "7c144e24-ca47-42a7-ba5b-86f3f1c38e5a",
        Description = "Block for child slides rendered in the Slider Block."
        )]
    public class SlideBlock : BlockData
    {
 
        [CultureSpecific]
        [Display(
            Name = "Image Link URL",
            Description = "URL where browser will be directed when image is clicked.",
            Prompt = "Image click target URL",
            GroupName = SystemTabNames.Content,
            Order = 10)]
        public virtual string ImageLinkUrl { getset; }
        
        [CultureSpecific]
        [Display(
            Name = "Image Src",
            Description = "Src attribute for image tag.",
            Prompt = "Where image resides",
            GroupName = SystemTabNames.Content,
            Order = 20)]
        public virtual string ImageSrc { getset; }
 
        [CultureSpecific]
        [Display(
            Name = "Image Alt",
            Description = "Alt attribute for image tag.",
            Prompt = "Alt attribute for image",
            GroupName = SystemTabNames.Content,
            Order = 30)]
        public virtual string ImageAlt { getset; }
 
        [CultureSpecific]
        [Display(
            Name = "Image Title",
            Description = "Title attribute for image tag.",
            Prompt = "Title attribute for image",
            GroupName = SystemTabNames.Content,
            Order = 40)]
        public virtual string ImageTitle { getset; }
 
        [CultureSpecific]
        [Display(
            Name = "CSS Class",
            Description = "Additional CSS class for the slide container div. This gets appended to .psSlide class.",
            Prompt = "",
            GroupName = SystemTabNames.Content,
            Order = 50)]
        public virtual string CssClass { getset; }
 
    }
 
}

What do I need to change to make these blocks appear?  Thanks for your help.

#113707
Nov 26, 2014 18:33
Vote:
 

Hi! In what path do you have your block view? If you don't have a custom view engine the standard location should be ~/Views/Shared/SlideBlock.cshtml.

#113732
Nov 27, 2014 9:11
Vote:
 

Thanks Mattias. That was the solution.  I had the view in a different directory.

#113911
Dec 01, 2014 14:55
Vote:
 

No problem Ken. If you want to use a different directory you can have your own ViewEngine:

public class MyViewEngine : RazorViewEngine
{
    public MyViewEngine()
    {
        PartialViewLocationFormats = PartialViewLocationFormats.Union(new[]
                      {
                          "~/Views/Shared/Blocks/{0}.cshtml"
                      }).ToArray();
    }
}

Register it in Application_Start in Global.asax.cs:

ViewEngines.Engines.Insert(0, new MyViewEngine());
#113939
Dec 02, 2014 8:24
Vote:
 

Thanks Mattias, that will come in useful.

#114007
Dec 02, 2014 17:34
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.