Skip to content

Portal themes: your own design for the customer and reseller portals

Enterprise

A portal theme replaces the look of the customer portal, the reseller portal and their sign-in pages with your own HTML and CSS. A theme is a zip with Twig templates and assets. NexoVirt keeps control of the data, the forms that matter for security and the scripts that protect the session, so a theme changes how the portal looks, never what a customer may do.

Portal themes need an Enterprise licence. When the licence lapses, every portal shows the default design again; stored themes stay and can still be deactivated, downloaded and deleted.

The portal theme reference lists every page, its variables, actions and fixed blocks. It is generated from the panel code (php spark docs:portal-themes), so it always matches what templates receive.

  1. Write a theme.json, a templates/layout.twig and the page templates you want to change (see below).
  2. Zip the folder (the files may sit in one top folder inside the zip).
  3. Open Customer portal > Themes and use Upload theme. The panel checks every file and compiles every template in the sandbox. The Themes table lists every theme with Version, Status, Pages, In use and Uploaded; open a theme to see its Problems found (with file and line), its Pages and the previews. While a theme has errors it cannot be activated. Warnings (for example a deprecated variable) do not block it.
  4. Look at it: the eye button Preview with sample data renders any page the theme covers with example data, and Preview as a customer on the theme’s page opens the portal as a chosen customer with this theme (only for you).
  5. Activate it: pick it in the Portals card at the top of the Themes page (one picture picker per portal, Customer portal and Reseller portal; Default design is the NexoVirt look), or use Activate for the customer portal / Activate for the reseller portal on the theme’s page. Customers see the change on their next page.

You can start small: every page template is optional. A page without a template renders the default page in the default design. The Pages card on the theme’s page shows which pages have no template, so you see the gaps before activating.

theme.json
screenshot.png optional, also .jpg or .webp
LICENSE optional, also LICENSE.txt
templates/
layout.twig required
ssh_keys.twig one file per page, all optional
servers/index.twig
auth/login.twig
partials/card.twig any partials you include
assets/
css/site.css
js/site.js
img/logo.svg
fonts/brand.woff2

theme.json:

{
"name": "My theme",
"slug": "my-theme",
"version": "1.0.0",
"author": "Example Hosting",
"description": "Our portal design.",
"api": 1,
"scope": "both"
}
  • name: 1 to 60 characters. slug: 2 to 41 lower-case letters, digits or dashes. version: like 1.0.0. The same slug and version cannot be uploaded twice: delete the old one first or raise the version.
  • author (up to 80 characters) and description (up to 300) are optional; screenshot names a screenshot file in the top folder. The panel shows it in the theme list and in the portal pickers under Customer portal > Themes; take it at 16:10 (for example 1280 x 800). A theme without one is shown as a small live render of its sample preview.
  • api: the contract version the theme was written for (see Versions and upgrades).
  • scope: customer (customer portal and customer sign-in pages), reseller (reseller portal and reseller sign-in pages) or both.

Rules for the files:

  • Only the files shown above are allowed in the top folder. templates/ holds .twig files only. assets/ holds css, js, json, png, jpg, jpeg, gif, webp, svg, ico, woff, woff2, ttf and otf files.
  • File names use ASCII letters, digits, dot, dash and underscore, with no leading dot. Extensions must be lower case (site.css, not site.CSS). Names with a second extension such as x.php.css are refused.
  • No PHP, no archives inside the theme, no symlinks, no absolute paths or ... SVG files are cleaned on upload (scripts and event handlers removed).
  • Limits: the zip at most 20 MiB, 60 MiB unpacked, 1000 files, 5 MiB per file, 256 KiB per template, 64 KiB for theme.json. __MACOSX folders and .DS_Store files are skipped.

Templates use Twig 3 in sandbox mode. Every page template usually extends the layout:

{# templates/layout.twig #}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{ page.title }} | {{ brand.name }}</title>
<link rel="stylesheet" href="{{ asset('css/site.css') }}">
<script src="{{ asset('js/site.js') }}" defer></script>
</head>
<body>
{% if frame %}
<nav>
{% for item in frame.nav %}
<a href="{{ item.url }}"{% if item.active %} aria-current="page"{% endif %}>{{ item.label }}</a>
{% endfor %}
</nav>
{% endif %}
<main>{% block content %}{% endblock %}</main>
</body>
</html>
{# templates/ssh_keys.twig #}
{% extends 'layout.twig' %}
{% block content %}
<h1>{{ page.title }}</h1>
{% for key in keys %}
<form method="post" action="{{ key.delete_url }}">
{{ csrf_field() }}
{{ key.name }} <code>{{ key.fingerprint }}</code>
<button type="submit">Delete</button>
</form>
{% endfor %}
<form method="post" action="{{ url('ssh_keys') }}">
{{ csrf_field() }}
<input name="name"> <textarea name="public_key"></textarea>
<button type="submit">Add key</button>
</form>
{% endblock %}

Every template gets the globals (brand, user, flash, features, can, frame, theme, page, nx) plus the variables of its page. Values are plain data, already filtered to what the customer may see: internal node names, storage and host details never reach a template, and portal feature switches apply first. Output is escaped automatically; values of type html are already safe.

Anything outside these lists is refused when the theme is uploaded:

  • Tags: apply, block, embed, extends, for, from, if, import, include, macro, set, with, verbatim.
  • Filters: abs, batch, capitalize, column, date, default, e, escape, filter, first, format, join, json_encode, keys, last, length, lower, map, merge, nl2br, number_format, replace, reverse, round, slice, sort, split, striptags, title, trim, upper, url_encode.
  • Functions: date, max, min, parent (inside a block of a template that extends another), and the NexoVirt helpers below.
  • Tests: Twig’s plain tests (defined, empty, null, even, odd, iterable, divisible by, same as …). The constant test is refused.

Refused on purpose: the raw filter, autoescape, constant(), attribute(), block(), source(), the range operator .., _self and _context (so macros live in their own file: {% import 'macros.twig' as m %}), and any method or property of an object (only the fixed blocks on nx can be called). include, import, extends and embed only load templates of the theme itself. map, filter and sort take arrow functions only.

HelperWhat it does
url(name, params)Link to a contract route, e.g. url('ticket', {number: ticket.number}). The route names are in the reference.
asset(path)URL of a file below assets/, cache-busted by its content, e.g. asset('css/site.css').
csrf_field()The hidden CSRF input. Every form that posts needs it.
money(cents)An amount in cents in the shop currency.
feature(key), can(action)True when the portal feature is on / the page allows the action.
t(text)Returns the text (reserved for translations).

Forms post to the existing portal routes with the same validation, CSRF check, rate limits and permissions as the default design. The reference lists every action of a page: method, target, fields and the errors it can show. Errors and success messages come back as flash on the next page. Put {{ csrf_field() }} in every form that posts.

Forms on themed pages may only post to the panel itself (form-action 'self'): a form pointing at another site does not submit.

  • CSS only through stylesheets loaded with asset(). Inline <style> elements are removed from the output.
  • Scripts only through <script src="{{ asset('js/...') }}"> with exactly the URL asset() gives. Every other script (inline, external, panel scripts, URLs with .., ? or #) is removed. No inline event handlers (onclick and the like) run: the panel’s Content Security Policy blocks them.
  • No external assets: fonts, images and CSS come from the theme’s own assets/ folder.
  • These elements are removed from theme output: script (except the theme’s own JS as above), noscript, noembed, noframes, xmp, plaintext, iframe, object, embed, template, style, and title / style inside inline svg or math. Give an inline SVG an aria-label instead of a <title>.

Theme scripts are left out:

  • on every sign-in, two-factor, sign-up, confirmation, inbox and password page (a script could read the password fields);
  • on the account settings page (password, two-factor, passkeys, API keys) and the VPN page;
  • on the reseller security page and the reseller API tokens page;
  • while an admin views the portal as a customer or previews a theme (a banner says “Theme scripts are off while you view the portal as a customer”);
  • for reseller themes (later phase): templates, CSS and images only.

NexoVirt’s widget library and block scripts run in all of these cases.

A theme should therefore work without its own JavaScript.

On every themed page NexoVirt adds its own parts, which a theme cannot remove: the CSRF meta tag, the core script and stylesheet (CSRF header for fetch, minimal nxAlert, nxConfirm and nxPrompt fallbacks, which your own JS may replace), the flash messages, and while an admin impersonates a customer a “back to admin” link. Style them with the nx- classes.

The fastest way in is the starter theme: a complete theme for every portal page (sign-in pages, dashboard, servers and the server page, shop and order page, services, balance, tickets, account security, VPN and the rest), written in plain HTML and CSS without JavaScript. Download it from Customer portal > Themes (Starter theme) or here, change it, raise the version in theme.json, zip it and upload it under your own slug.

theme.json slug nexovirt-starter, api 1, scope both, version 1.1.1
templates/
layout.twig the shell: sidebar navigation, top bar, flash, page header
dashboard.twig, servers/, services/, shop/, tickets/, ... one template per page
auth/, reseller/auth/ sign-in pages
reseller/ reseller portal pages (dashboard, customers, servers, products, support, orders, ...)
partials/ shared parts (icons.twig, nav.twig, ui.twig, server/*.twig panes of the server page)
assets/css/starter.css every style, light and dark through prefers-color-scheme
assets/img/empty.svg empty-state picture
  • All classes of the starter start with sx- (sx-shell, sx-sidebar, sx-card, sx-card-header, sx-card-body, sx-stats, sx-button, sx-button-primary, sx-input, sx-field, sx-alert, sx-badge, sx-meter …). Colours are custom properties at the top of starter.css (--sx-accent, --sx-fg, --sx-surface, --sx-line …), with a dark set in the prefers-color-scheme: dark block. Change those first.
  • NexoVirt’s own markup (fixed blocks, widgets, tables) uses nx- classes; the starter styles them too, so copy those rules when you start a theme of your own.
  • The starter picks up your brand: brand.name, brand.logo_url and the brand colour NexoVirt injects as --nx-brand (--sx-accent follows it).

NexoVirt Slate is a second ready-made theme: a dark slate portal with an icon rail, a top menu, figure cards and soft status pills, also plain CSS without JavaScript, for the customer and the reseller portal. Download it here and upload it under Customer portal > Themes as it is, or use it as a starting point like the starter.

Live parts of the portal (server status, power buttons, live charts, the console, the provisioning progress, payment status, tables of snapshots, backups, firewall rules and more) are NexoVirt widgets. NexoVirt loads its widget library nexovirt-portal.js on every themed portal page except the sign-in pages, also when theme scripts are off, so a theme needs no JavaScript of its own. A widget is configured with data-* attributes only:

<div data-nx-widget="status" data-nx-src="{{ server.urls.status }}">
<span data-nx-field="status"></span>, up <span data-nx-field="uptime"></span>
</div>
<div data-nx-widget="power" data-nx-src="{{ server.urls.power }}" data-nx-status="{{ server.urls.status }}">
<button data-nx-power="start">Start</button>
<button data-nx-power="stop" data-nx-confirm="Stop this server now?">Stop</button>
</div>
<div data-nx-widget="table" data-nx-src="{{ server.snapshots.data_url }}"
data-nx-columns="name:Name,snaptime:Created:datetime"
data-nx-row-action-0="Delete|{{ server.snapshots.delete_url }}|Delete this snapshot?" data-nx-row-body-0="snapname:name"></div>

The reference lists every widget with its attributes, every window.NexoPortal function (get, post, poll, toast, confirm, prompt, register, mount, allowedUrl) and the events (nx:status, nx:done, nx:error, nx:reloaded). The rules:

  • Addresses: a widget only talks to addresses of this panel below /portal/ (from the page’s variables). Anything else (another site, //host, /panel/..., a path with .. or an encoded slash) mounts nothing.
  • Gestures: widgets read (GET) on their own. A change (POST) is only sent after a real click or submit by the customer, never from a script-dispatched event, and always with the CSRF token.
  • Per page: a built-in widget mounts only on the pages that list it (see “Widgets” on each page in the reference). At most 8 live polls run on a page.
  • Theme JavaScript (where it runs) can use the same functions and add own widgets with NexoPortal.register(name, fn).

Forms that carry secrets or money are fixed blocks: the template calls the block and NexoVirt puts the real form in its place. The template never sees the form markup and its values. The same placement rules as on the sign-in pages apply.

PageRequiredOptional
securitynx.password_form(), nx.two_factor_setup()nx.passkeys(), nx.api_keys()
vpnnx.vpn_devices()
servers/shownx.reinstall_form(), nx.root_password_form()
servers/setupnx.setup_form()
servers/newnx.server_create_form()
shop/ordernx.order_form()
services/shownx.remote_password_form()
reseller/securitynx.password_form(), nx.two_factor_setup()nx.passkeys()
reseller/api_tokensnx.api_token_form()
reseller/guests/shownx.reinstall_form(), nx.root_password_form()
  • A required block must be called exactly once; an optional one at most once. Calling a block on a page that does not list it is an upload error.
  • If the operator requires two-factor sign-in, a theme without nx.two_factor_setup() on security is refused, and a stored theme that breaks falls back to the default page, so a customer can always enrol. The same holds for reseller/security when two-factor is required for customers and resellers.
  • A block whose feature is off for the customer (for example reinstall) renders an empty element; check can before you place a heading for it.
  • What stays NexoVirt’s: account password, two-factor secret, QR code and recovery codes, passkeys, API keys, VPN keys and configs, root passwords, the remote panel password, and the order form (OS, root password, add-ons, coupon, consent checkboxes, billing and payment buttons). The rest of the order page (product, periods, specs, price, stock) is themable data.

Theme scripts never run on the sign-in pages, on security (password, two-factor, passkeys, API keys), on vpn (VPN keys and configs), on reseller/security and on reseller/api_tokens (the new token is shown once by NexoVirt). The reference marks them with “Theme JavaScript: never runs on this page”. NexoVirt’s widgets and block scripts still run there. On the server, order and setup pages theme scripts do run: such a script acts with the customer’s session anyway, so hiding those forms from it would protect nothing.

Activate a theme with scope reseller or both for the Reseller portal slot under Customer portal > Themes. It restyles the reseller sign-in and every themable page of the reseller portal: dashboard, customers (list, portal features, SSH keys, groups), servers and the server page, products and size templates, categories, IP pools, API tokens, support tickets and FAQ, orders, notices and security. Templates live under templates/reseller/; the pages are listed in the reference with “Area: reseller portal”.

  • The customer slot and the reseller slot never mix: customers of a reseller get the customer portal theme, resellers get the reseller portal theme.
  • Every page shows only the reseller’s own customers, servers, products, orders and tickets, the same as the default design. Widgets on reseller pages only accept /reseller/ addresses.
  • The frame variable has the same shape as on the customer portal; balance is null and the notice lists are empty.
  • The reseller portal only uses themes you upload. Resellers can upload themes for their own customers, see Reseller themes.

These editors are shared with the operator panel and keep the NexoVirt design while a theme is active. The Themes page lists them under “Always shown in the NexoVirt design”; link to them from your templates as usual.

PagePath
Product form/reseller/products/new
Size template form/reseller/plans/new
Category form/reseller/products/categories/new
Create server/reseller/guests/new
Customer group form/reseller/customers/groups/new
Notice form/reseller/notices/new
Branding/reseller/branding
Legal texts/reseller/legal

The edit pages of products, categories, groups and notices use the same editors.

A reseller can upload its own theme for its own customers’ customer portal. It never changes the reseller portal and never reaches customers of other resellers or your own customers.

Switch it on (admin): on the reseller’s edit page, section Account, turn on May upload own portal themes under Portal themes. Without it the reseller has no Themes menu item and its themes are not used. Turning it off takes effect at once: its customers get your customer portal theme again, the stored themes stay.

Upload and activate (reseller): the reseller portal menu item Themes has the same page as yours: Upload theme, Starter theme (covers every customer page), the eye button Preview with sample data and a Portals card with one picker for the Customer portal. Default design there means the provider’s customer theme (or the NexoVirt design); pick it to stop using the reseller’s theme.

  • No JavaScript. An upload with .js files is refused with “Themes for your customers cannot contain JavaScript files. Remove the .js files and upload again.”. NexoVirt’s own widgets and block scripts still run on its pages.
  • Scope in theme.json must be customer or both; a reseller theme is refused.
  • Limits: at most 10 themes per reseller (“You can keep at most 10 themes. Delete one first.”) and 10 uploads per hour (“Too many uploads. Try again later.”). The package rules are the same as for your themes.
  • Preview: sample data only. There is no preview as a customer; the preview page says “Theme scripts are off in this preview”.

Which theme a customer sees: the reseller’s active theme (switch on) > your Customer portal theme > the default design. Before sign-in, the reseller’s theme is used on the reseller’s portal domain; everywhere else your theme. Safe mode and a lapsed Enterprise licence put reseller themes on the default design too. A page the reseller’s theme does not cover falls back to the default design (not to your theme); a reseller theme that fails the check (for example after a panel update) gives way to your theme.

What you see: Customer portal > Themes lists Reseller themes (reseller, theme, version, status). You can download or delete them, never activate or preview them.

Themed pages may only post forms to the panel itself (form-action 'self'). Paying at a gateway (Stripe, PayPal) and “Open in Plesk” leave the panel, so while a customer theme is active NexoVirt answers those posts with a short same-origin page (/portal/continue/...) that moves on to the gateway or panel by itself, with a link as a fallback. The page is NexoVirt’s (never themed), works once, for 5 minutes, only in the same session, and only for https targets. Without a theme the redirect goes straight to the target as before. After the payment the customer comes back to the checkout page, whose checkout widget follows the payment and opens the next page.

Panes that read live data (snapshots, backups, firewall rules, CD/DVD, boot settings, reinstall options, SSH keys for root, IP lists) stay on their existing JSON endpoints. Each page in the reference lists its endpoints under “Endpoints” with the method, the address variable to use and every response field. Use them through the table and form widgets or from theme JavaScript with NexoPortal.get(). The same filters apply as on the default pages: portal features, the share role, locks and suspension. A theme cannot reach data the customer could not see on the default page.

The theme can restyle /portal/login (customers) and /reseller/login (resellers), the two-factor step, sign-up, sign-up confirmation and password reset. The admin sign-in at /login is never themed. On a host that belongs to the customer or reseller portal, /login forwards to that portal’s sign-in page.

The forms on these pages are fixed blocks: the template calls for example {{ nx.signin_form() }} and NexoVirt puts the real form (fields, CSRF, captcha, passkey and SSO buttons, their scripts) in its place after rendering. The template never sees the form markup.

PageRequired block
auth/login, reseller/auth/loginnx.signin_form()
auth/two_factor, reseller/auth/two_factornx.two_factor_form()
auth/registernx.register_form()
auth/register_inbox, auth/register_confirmnx.register_confirm_form()
auth/forgot_passwordnx.forgot_form()
auth/reset_passwordnx.reset_form()

Rules (checked at upload and again on every render; a page that breaks them shows the default design):

  • Call each required block exactly once, where it is really printed (not in a condition that is false, not in a comment).
  • Not inside a form, a, label, button, select, textarea, inside inline svg or math, and not in table structure outside a cell (put it in a td, not straight in a table or tr).
  • Do not reuse the ids of the block elements (they start with nx-).
  • The two-factor block has one code field that takes an authenticator code or a recovery code.
  • On the sign-up page, switching the account type (private, company) reloads the page with that type.
  • The inbox page must call nx.register_confirm_form(): with code confirmation it holds the code field, with link confirmation it renders nothing.

Blocks carry plain markup with nx- classes, so your CSS can style them.

  • Preview with sample data renders a page with the example data from the reference. Forms in it are not meant to be used.
  • Preview as a customer signs you in as the chosen customer with the theme, without activating it. Theme scripts stay off; use back to admin to return.
  • Safe mode (on the Themes page) puts every portal on the default design at once. Active themes are kept and come back when you turn it off. A theme preview as a customer still works while safe mode is on, so you can test a fix.

From the command line (as the panel user):

Terminal window
php spark portal:theme --status # active theme per portal, safe mode, every theme
php spark portal:theme --default # safe mode on
php spark portal:theme --resume # safe mode off
php spark portal:theme --revalidate # check every stored theme against the current contract

The page contract (variables, routes and blocks of every page) has a version, set as api in theme.json. NexoVirt keeps a version stable across updates: renaming or removing a variable means a new contract version, and the old one stays supported for at least 12 months after its successor ships. The reference shows the current version and the supported ones.

After a panel update the stored themes are checked again. A template that uses a variable or block that is gone fails the check: the theme is marked invalid on the Themes page, the portal shows the default design for it, and the diagnostics log NX-THEME-0002. Deprecated variables are warnings with the name to use instead. A theme whose contract version is no longer supported falls back to the default design.

  • A page shows the default design. The template failed to render or the page has no template. Diagnostics shows NX-THEME-0001 with the theme, template, line and message (one entry per template every 10 minutes).
  • The theme will not activate. Fix the errors listed on its row and upload a new version.
  • The portal is broken for everyone. Turn on safe mode (Themes page or php spark portal:theme --default).
  • My script does not run. Check the list above: no JS on sign-in pages, security, vpn, reseller/security, reseller/api_tokens, during previews or impersonation, and only through asset().
  • A widget does nothing. The page must list the widget, and its address must come from the page’s variables (a portal address of this panel). Several widgets on one page share at most 8 live polls; past that a widget shows an error state.
  • My inline styles are gone. Move them into a stylesheet in assets/.

NexoVirt is developed and designed by Nucez Software, your partner for custom software and web design.