EPiServer

Shorter epi prefix for EPiServer:Property

Posted on Updated on

Declaration of a property output in Page.aspx. This is one the most common code through the whole solution.

<EPiServer:Property runat="server" PropertyName="ContactsArea"></EPiServer:Property>

I like to make repetitive markup to be smaller and have:

<epi:Property runat="server" PropertyName="ContactsArea"></epi:Property>

In your web.confing instead of

<add tagPrefix="EPiServer" namespace="EPiServer.Web.WebControls" assembly="EPiServer" />
<add tagPrefix="EPiServer" namespace="EPiServer.Web.WebControls" assembly="EPiServer.Web.WebControls" />
<add tagPrefix="EPiServer" namespace="EPiServer.Framework.Web.WebControls" assembly="EPiServer.Framework" />

you put:

<add tagPrefix="epi" namespace="EPiServer.Web.WebControls" assembly="EPiServer" />
<add tagPrefix="epi" namespace="EPiServer.Web.WebControls" assembly="EPiServer.Web.WebControls" />
<add tagPrefix="epi" namespace="EPiServer.Framework.Web.WebControls" assembly="EPiServer.Framework" />

Why I don’t like Web Forms in EPiServer

Posted on Updated on

It can be avoided using Macio code (lambdas).

Feedback after academy

Posted on

I had an Academy today. It’s a time when anybody from company can have a presentation on any topic. I had a presentation about EPiServer 7 (MVC) development.

I want to point the feedback I get to not forget it for the next Academy:

  • I could focus on less topics, but cover them more deeply with more examples
  • It was too much chaotic, I was not following a plan (there was no strict plan, let’s say). And it would be difficult to make the same presentation again.

Fill CurrentPage after PostBack in MVC

Posted on

public class PageContextActionFilter : IResultFilter
{
    private readonly IContentLoader _contentLoader;

    public PageContextActionFilter(IContentLoader contentLoader)
    {
        _contentLoader = contentLoader;
    }

    public void OnResultExecuting(ResultExecutingContext filterContext)
    {
        var model = filterContext.Controller.ViewData.Model as IPageViewModel<StandardPage>;
        if (model == null)
            return;

        // code like in Alloy Template

        // When ViewModel is posted back to server by POST, CurrentPage is null, so its set here
        if (model.CurrentPage == null)
        {
            var pageReferene = filterContext.RequestContext.GetContentLink();
            var concreteModel = model as PageViewModel<StandardPage>;
            if (concreteModel != null)
            {
                var currentPage = _contentLoader.Get<StandardPage>(pageReferene);
                concreteModel.CurrentPage = currentPage;
            }
        }
    }

    public void OnResultExecuted(ResultExecutedContext filterContext) { }
}

TinyMCE in EPiServer

Posted on

You can embed a video using TinyMCE, and there is even a preview:
insert video in TinyMCE EPiServer

Defenition of done

Posted on

For EPi page/task (still WIP)

• Validators
• Localization of everything user visible (this is tricky, sometimes it’s better to leave it to one person responsibly for this near the end).
• Description of done things, funny, some info funny info for customer like in Joel.
• Explain to person responsible for contacting customer, but first let them read the Description from previous point.

EPiServer misc

Posted on Updated on

Post that is constantly being edited.

ImageAlternateText is better name than ImageDescription, then we are talkinga bout alt attribute needed for images.

string.IsNullOrEmpty(Container.Item.Intro ?? “”) – czy gdy wrocimy do pustego to bedzie null czy puste?
– gdy wrócimy do pustego to jest nullem, więc nie trzeba żadnych IsNullOrEmpty() robić.

private readonly IContentLoader _contentLoader;
Zamiast IContentRepository

var currentContextPage = ControllerContext.RequestContext.GetContentLink();

From

[Required] nadawać na rzeczy od których zależy logika w innych miejscach. Czyli gdy jest to:

[Required]
[UIHint("CatalogNode")]
[BackingType(typeof(CatalogNodeBrowserProperty))]
public virtual string CatalogNode { get; set; }

W przypadku rzeczy które też muszą być, ale ostatecznie będzie tylko gorzej wyglądać to bym nie ograniczał:

[CultureSpecific]
public virtual String Subtitle { get; set; }

Rebuild index in Episerver Commerce

Posted on

rebuild index episerver commerce

Later restart Apache Tomcat service.

At least it works in my case.

Then OnPageEdit is missing

Posted on

Episerver has a helper method @Html.DisplayFor(m => m.MainIntro) which basically writes MainIntro in ViewMode and make editable green rectangle in EditMode (OnPageEdit). But not always it works and I don’t know why. Below are some tricks to force it to render blue (green when hoovering) rectangle while in OnPageEdit. First is just string, second is ContentArea.

    <div class="intro" @Html.EditAttributes(m => m.CurrentPage.MainIntro)>
        @Html.PropertyFor(m => m.CurrentPage.MainIntro)
    </div>

onPageEdit episerver 7

There is @Html.DisplayFor here

    if (PageEditing.PageIsInEditMode)
    {
        <div class="footer-partners">
           @Html.DisplayFor(m => m.Footer, new { CssClass = "footer-partners", EditContainerClass = "footer-partners" })
        </div>
    }
    else
    {
       @Html.DisplayFor(m => m.Footer, new { CssClass = "footer-partners", EditContainerClass = "footer-partners" })
    }

I am using EditContainerClass like in the post How EPiServer’s HTML helper PropertyFor works. Maybe on my pages there is something wrong in the markup in other places and we don’t have time to investigate? I am just Back End developer and this tricks helped me 🙂

Passing data to built-in framework properties

Posted on

You will need to override the default rendering of i.e. LinkItemCollection

@Html.PropertyFor(x => x.Links, new { @class="nav nav-tabs"})
@using EPiServer.SpecializedProperties
@model LinkItemCollection
<ul class="@ViewData["class"]">
    @foreach(var linkItem in Model ?? Enumerable.Empty<LinkItem>())
    {
        <li class="@ViewData["itemClass"]">@Html.PageLink(linkItem)</li>
    }
</ul>

http://joelabrahamsson.com/episerver-7-and-mvc-how-to-customize-rendering-of-properties/