Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

collective.fragmentsblock

A Fragment block for the Aurora editor in Plone Blicca.

A fragment is a static piece of HTML, usually cut straight from the design mockup: a contact box, a seal, a call-to-action banner, a partner-logo strip. Your theme ships it as a file in a folder it registers with one line of ZCML. Editors then pick it from a list and drop it into a page. The markup is rendered exactly as it is in the file, both in the editor and on published pages.

Editors never edit the markup. When the file changes, every page using the fragment updates on the next deployment.

Installation

Add collective.fragmentsblock to your project dependencies and install it in the Plone add-ons control panel.

Requirements: Plone 6, Python 3.10 or newer, and plone.blicca.auroraeditor 1.0.0a4 or newer, the Plate 53 editor. The editor waits for this block to fetch its fragments before it renders.

This package only provides the block. Fragments come from your own add-on, typically the theme package. See the next section.

Register a fragment

Fragments live in a folder of your add-on, one HTML file per fragment. The server reads the files when it renders classic pages, and the editor fetches the same files from the server when it opens. Nothing is built, bundled or copied.

src/my/theme/
├── fragments/
│   ├── contact-box.html
│   └── seal.html
└── configure.zcml

The file name is the fragment id. Ids must match ^[A-Za-z0-9][A-Za-z0-9_-]*$ and are unique across the whole site, so prefix them if more than one add-on may provide fragments. A file whose name is not a valid id is skipped with a warning.

Register the folder in your configure.zcml:

<!-- my/theme/configure.zcml -->
<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:fragments="http://namespaces.plone.org/fragmentsblock">

  <include package="collective.fragmentsblock" file="meta.zcml" />

  <fragments:folder directory="fragments" />

</configure>

directory is relative to your package. The folder is registered under your package name. Pass name="..." if you need another one. A folder that does not exist is an error at startup, not an empty picker.

That is all. Restart Plone and the fragments appear in the picker.

Titles

Editors pick a fragment by its title. Put it in a comment on the first line of the file:

<!-- title: Contact box -->
<aside class="contact-box">
  ...
</aside>

Without that comment the title is derived from the file name: contact-box.html becomes "Contact box", partner_logos.html becomes "Partner logos". The comment is part of the markup and is rendered with it; browsers ignore it.

Add a fragment to a page

  1. Open the page in the Aurora editor.
  2. Type / and choose Fragment from the slash menu.
  3. In the block settings, pick the fragment from the Fragment list.

The fragment renders immediately. Two more settings control placement:

  • Block width: narrow, default, layout or full. Defaults to default.
  • Background: a named colour slot from your theme's palette, such as Grey or Accent. The field only appears if the theme registers a palette.

Both paint the block wrapper around the fragment, not the fragment itself.

If a fragment's add-on gets uninstalled, the editor shows a note in place of the block and the published page renders nothing there. Pages never break.

Good to know

  • Fragment HTML is trusted. It ships with your add-on and is not sanitised. A <script> in it runs on the published page.
  • Variables. Markup may contain ${name} tokens. They are filled from the block's variables mapping, HTML-escaped, with missing names rendered empty. There is no editor UI for this yet. The mapping can be set through the REST API or an upgrade step. For now, if a fragment needs different values on different pages, ship one fragment per variant.
  • Wrapper. Both the editor and the server wrap the markup in a <div class="block-fragment">. Mockup HTML written for a grid or flex parent needs to account for that.
  • The editor fetches @fragments. When the editor opens, the fragment block requests <site>/@fragments with the session cookie and registers what comes back before the first render. The list is every provider's records(); where two providers use the same id, the one whose name sorts first wins, on both surfaces. If the request fails, the block stays available with an empty picker and existing fragment blocks say so instead of rendering nothing.
  • Other sources. A folder of files is the stock provider. For anything else, register a named utility that implements IFragmentsProvider: get(fragment_id) returns the HTML or None, and records() lists every fragment as {"id", "title", "html"}.
  • Registering from JavaScript still works. An Aurora add-on may register fragments itself, with registerFragment(config, {id, title, html}) from the npm package @plone-collective/aurora-fragment-block or with a bare config.registerUtility of type collective.fragmentsblock.fragment. The server then needs a matching provider, or the fragment renders only in the editor.

Development

The editor half lives in bundle-src/ and is built into the Python package's static/ folder. The build output is committed.

cd bundle-src
pnpm install
pnpm build
pnpm test

Python tests:

uv run --extra test pytest

License

GPLv2 for the Python package, MIT for the npm package.

Author

Maik Derstappen, derico.de, md@derico.de

Metadata

Release files for collective.fragmentsblock 1.0.0a4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for collective.fragmentsblock 1.0.0a4
File Size Uploaded Provenance Actions
collective_fragmentsblock-1.0.0a4.tar.gz 312.8 kB Without provenance Details for collective_fragmentsblock-1.0.0a4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for collective.fragmentsblock 1.0.0a4
File Interpreter ABI Platform Actions
collective_fragmentsblock-1.0.0a4-py3-none-any.whl Python 3 none any Details for collective_fragmentsblock-1.0.0a4-py3-none-any.whl

Total release size: 365.3 kB

Release files / collective_fragmentsblock-1.0.0a4.tar.gz

Download URL collective_fragmentsblock-1.0.0a4.tar.gz
Size 312.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3ffe82d7d825bb44b4eb65cd1a402a4d342789b380f898a1d461ac28b1329018
BLAKE2b-256 checksum
How to use checksums
d78f712b38b555cd48969a746745d3e9b5309732ac349bac86e4830e4c66d562
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / collective_fragmentsblock-1.0.0a4-py3-none-any.whl

Download URL collective_fragmentsblock-1.0.0a4-py3-none-any.whl
Size 52.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
259de86c3df18e8e4499f173594c889fba0bc42c34ccbc603115a22b82a659fd
BLAKE2b-256 checksum
How to use checksums
cdea2ecf8a21dae4cbfc164c5a6dd5776d6b84654d25c075ab01d9bf7088157b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for collective.fragmentsblock 1.0.0a4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page