łukasz solana
łukasz solana

Reputation: 33

Reload Content Editor after selecting language using language switcher

I'm trying to reload content editor content based on selected language as I need to filter items before user can see them. Right now I am able to filter items by inheriting from BucketDataView and overriding GetChildItems method.

Is there a way to refresh content after selecting new language but after filter is called?

If my approach is wrong, what else can I use?

Thanks!

Lukasz.

Upvotes: 1

Views: 293

Answers (2)

łukasz solana
łukasz solana

Reputation: 33

Working solution

Create a new command

[Serializable]
public class SelectLanguage : Languages
{
    public override string GetClick(Sitecore.Shell.Framework.Commands.CommandContext context, string click)
    {
        Sitecore.Context.ClientPage.SendMessage(this, string.Format("item:refreshchildren(id={0})", Sitecore.ItemIDs.ContentRoot));

        return base.GetClick(context, click);
    }

}

Update \Website\App_Config\Commands.config

Set <command name="ribbon:languages" type="[Namespace]SelectLanguage ,[assembly]"/>

In this case I am able to update content tree after selecting new language in language switcher.

Łukasz.

Upvotes: 1

Jan Bluemink
Jan Bluemink

Reputation: 3487

This is possible and works great. It is well explained in one of my favorite post from John West. load-or-reload-an-item-in-the-sitecore-aspnet-cms

You can use it for example inside a Command see dialoge-box-in-een-command for some code.

Alternative Use a url, See open-content-editor-on-specific-item

Upvotes: 1

Related Questions