Inserting HTML

If your module need to change the appearance of the application or add markup to any of the layouts, you can use the inserting HTML functionality in the module framework.

class Identity < Module

  add_template_item :all, :top do |config, account, user|
    ## This method should return a string of HTML which will be inserted into the
    ## appropriate position in the specified layout.
    "<h2>My module has been inserted nicely!</h2>"
  end

  add_ticket_tab "Custom Tab" do |config, account, user, ticket|
    ## This method should return a string of HTML will will be inserted into the
    ## body of your custom ticket tab.
    "<dl><dt>Subject:</dt><dd>#{ticket.subject}</dd></dl>"
  end

end

Using add_template_item

The first parameter is the layout which you wish to insert into. This should be one of the following:

  • :admin: - to insert into the admin UI
  • :staff - to insert into the staff tickets UI
  • :reporting - to insert into the reporting UI
  • :knowledge - to insert into the staff knowledge base UI
  • :public - to insert into all public interfaces
  • :all - to insert into all the layouts

The second parameter is the position you wish to insert into. This should be one of the following:

  • :head - just before the closing </head> tag.
  • :top - immediately following the opening <body> tag.
  • :bottom - immediately preceding the closing </body> tag.

When the block is executed, it is provided with three objects:

  • config - contains a hash of the configuration for the account. See the configuration page for further details.
  • account - contains the account object for the current account.
  • user - contains either a User object (for any user authenticated pages) or a Customer object for the public interface layouts. This is the currently logged in user and could also be nil or false in various circumstances.

It is important that the block returns a string containing the valid HTML you wish to insert. If you're looking to change CSS, you should use the :head position and use <style> tags.

Using add_ticket_tab

Ticket tabs are only displayed on ticket detail views and will be rendered along with the standard tabs, after any custom data frames.

The first parameter is the name that you wish to appear in the tab selection bar. When the user clicks on this the body of your ticket will be displayed.

When the block is executed, it is provided with four objects:

  • config - contains a hash of the configuration for the account. See the configuration page for further details.
  • account - contains the account object for the current account.
  • user - contains either a User object relating to the currently logged in staff member
  • ticket contains the Ticket object for the page the tab is being rendered on

Proudly powered by Katapult. Running on 100% renewable energy.