volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Control custom tab visibility

Hi,

 

Is there a way for me to control the visibility of a custom tab based on the page type in Edit Mode. For example, I have a custom tab names External sources which is associated with a page type called referecences. If the page type is not this one, I would like to hide it.

 

Thanks

#35169
Nov 30, 2009 16:38

Yes, you can implement the interface EPiServer.PlugIn.ICustomPlugInLoader and then do like this

// Hide/show tab
        public PlugInDescriptor[] List()
        {
            PlugInDescriptor[] descriptors = null;

            // Check if we should show the plugin
            if (CurrentPage.PageTypeID == Utils.Settings.PageTypePressRelease || CurrentPage.PageTypeID == Utils.Settings.PageTypeFinancialReport)
            {
                descriptors = new PlugInDescriptor[1];
                descriptors[0] = PlugInDescriptor.Load(this.GetType());
            }
            // else return null
            return descriptors;
        }

Magic, huh? :)

#35172
Nov 30, 2009 17:22

It is magic, but where so I implement this?

#35209
Nov 30, 2009 23:56

Hi!

As Erik mentioned, implement the ICustomPlugInLoader interface for your tab-plugin to be able to decide if you want to create a plug-in or not for the current page. See the following example from the forms posting plug-in:

    [GuiPlugIn(DisplayName = "XFormdata",
                Description = "Show xformdata",
                Area = PlugInArea.EditPanel,
                UrlFromUi = "edit/XFormPostings.ascx",
                LanguagePath = "/edit/formpostings",
                RequiredAccess = AccessLevel.Edit)]
    public partial class XFormPostings : UserControlBase, ICustomPlugInLoader

...

...

        public PlugInDescriptor[] List()
        {
            if (!PageContainsFormProperties())
            {
                return new PlugInDescriptor[] { };
            }
            else
            {
                return new PlugInDescriptor[] { PlugInDescriptor.Load(typeof(XFormPostings)) };
            }
        }

 

Linus Ekström

#35295
Dec 03, 2009 9:25

Thanks perfect! It works like magic!

#35311
Dec 03, 2009 15:42
* 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.