How do I create a user profile route for my plugin?
-
Your plugin may want to expose some user-specific options, and to accomplish that, you'll want to create a page accessible from within their user profile.
In Harmony, plugin-added pages are added to the left-hand sidebar:
In Persona, plugin-added pages are behind the overflow menu:
You'll need to add listeners to two hooks, and modify your page template accordingly.
static:app.load
You'll need to specify a route in the user profile using this hook. In it, note the
accountMiddlewares
block, which contains some common middlewares that are sensible defaults. You'll needmiddleware.buildAccountData
in order to retrieve some boilerplate data that all account routes need.filter:user.profileMenu
You'll then want to specify the menu option, including label, icon, and visibility options.
visibility
allows you to specify which users can see the option (e.g. self only, admins only, etc.)The template
In your template for the user page, you'll want to prefix it with
<!-- IMPORT partials/account/header.tpl -->
and suffix it with<!-- IMPORT partials/account/footer.tpl -->
. These two lines will wrap your template content with the theme-specific structure. For example, in Harmony, a sidebar is used in the accounts pages. The header and footer partials will ensure they are also present in your template. Themiddleware.buildAccountData
middleware you added in the first step will ensure the data necessary is present.