Html
Static and multilingual HTML content for reusable page elements, resolved through APPNETOS language fallbacks and passed directly to the render layer.
Purpose
The HTML content handler embeds reusable static HTML elements into an APPNETOS page. Unlike an App content item, HTML content does not execute an app controller or render a Twig template. It loads stored HTML documents and prepares their markup for the rendering pipeline.
Multilingual HTML content
HTML content can be shared across languages or provided in language-specific variants. The handler
first
loads the global HTML document by the content item's ObjectId. If that document defines
a
non-empty content key, APPNETOS looks up corresponding language-specific documents using the active
fallback keys from Core\Languages.
If the global document has no content key, its HTML is used directly. If the collection does not provide language-key lookup, the global document is used instead. The selected document supplies the markup returned to the render layer.
Language-specific document selection depends on the results returned by the mapped collection. The handler iterates those results and retains the last valid HTML document, so collection result ordering matters for fallback precedence.
Processing lifecycle
- Receive the normalized URI content item and extract its ID and data.
- Load the active global HTML document through the context-specific collection.
- Resolve a language-specific document when a content key is available.
- Read the stored HTML markup and optionally pass it through the configured HTML compressor.
- Expose the prepared HTML through
getView()for aggregation byCore\Contentand subsequent rendering.
For AJAX requests, initialization skips document loading and HTML preparation. HTML collection mapping and compressor activation are supplied by the context-specific implementation.
Public API Reference
Core\Content\Html
Class & Registry
Class:
Core\Content\Html
Extends:
Core\Content\Html\Base
use Core\Content\Html;
use Core\Registry;
$html = Registry::get(Html::class);
| Method | Description |
|---|---|
init(array $item): void |
Initializes the handler once with a normalized content item. For non-AJAX requests, resolves the HTML document and prepares its output. |
getItem(): array |
Returns the normalized content item supplied during initialization. |
getId(): ObjectId|null |
Returns the content item's MongoDB ObjectId, or null when unavailable.
|
getData(): array |
Returns the additional data associated with the content item. |
getDocument(): object|null |
Returns the resolved global or language-specific HTML document, or null
if
none
was loaded.
|
getHtml(): string |
Returns the prepared HTML markup, including optional compression, or an empty string. |
getView(): string|null |
Returns the prepared HTML for rendering, or null when the HTML is
empty.
|