Wiki

Case Status Kiln
Register Log In

Wiki

 
"How To" Guides»How To Add a new page to FogBu…
  • RSS Feed

Last modified on 12/15/2014 5:18 PM by User.

Tags:

How To Add a new page to FogBugz

Interfaces: IPluginConfigPageDisplay, IPluginPageDisplay, IPluginRawPageDisplay, IPluginBinaryPageDisplay


The FogBugz plugin architecture allows for adding four different types of pages to FogBugz.  The most basic is the plain PageDisplay.

Normal Pages: IPluginPageDisplay

Normal pages are added by implementing IPluginPageDisplay:

public interface IPluginPageDisplay
{
string PageDisplay();
PermissionLevel PageVisibility();
}

The PageDisplay function just returns an HTML string to display in the page. The HTML is wrapped with the usual FogBugz UI.  PageVisibility determines the visibility or permission level of the page.  So if we wanted to create a page that is visible to Normal users and above (Normal and Administrator, but not Community or Public users), we would implement the following:

    #region IPluginPageDisplay Members

    public string PageDisplay()
    {
        return "<h1>Hello, world!</h1><p>This is my page.</p>";
    }

    public PermissionLevel PageVisibility()
    {
        return PermissionLevel.Normal;
    }

    #endregion

This adds a page that looks something like this:

If you want to have multiple normal pages, you can reuse this page by passing in parameters via the Request object and switching out the content. See also a full "Hello, world" example, Implementing IPluginPageDisplay and Simple Todo List Tutorial, which handles the use of Request parameters.

Other Pages: IPluginConfigPageDisplay, IPluginRawPageDisplay, IPluginBinaryPageDisplay

There are three other types of pages that plugins can implement: ConfigPages, RawPages, and BinaryPages.  All of these interfaces are essentially the same as NormalPage, with the following differences

  • IPluginConfigPageDisplay creates a configuration page for a plugin.  The configuration page is automatically linked to from the Plugins page, and is only accessible to Administrators. (Example)
     
  • IPluginRawPageDisplay creates a raw page that does not have the FogBugz user interface.  Use this page to send AJAX responses or other types of text data that should not display the interface.  When this page is being displayed, you can use the CPluginResponse object (api.Response) to set the content encoding, type, and disposition. (Example)
     
  • IPluginBinaryPageDisplay creates a binary page.  Instead of returning a string, this interface returns a byte array to be written to the HttpResponse.  Use this page to send binary files to the client.  When this page is being displayed, you can use the CPluginResponse object (api.Response) to set the content encoding, type, and disposition. (Example)

Linking to Plugin Pages

The CUrlApi object (api.Url) has methods for getting URLs to link to plugin pages.  For example,

api.Url.PluginPageUrl()

gets a string URL which points to the PluginPage. See Implementing IPluginExtrasMenu for an example of adding a link to the Extras menu.