Per Nergård (MVP)
Apr 18, 2016
  3906
(1 votes)

Limit block and page types to be created only once (updated)

Two years ago I did a hack that let you as a developer specify if a block or page type should be allowed to only be created once. Old post here. For some reason I can't remeber I used an interface to specify this. Now I have updated the code to use an attribute instead. 

Just decorate your models with [Singleton] and the initializationmodule will handle the rest.

Code over at Gist.

Apr 18, 2016

Comments

Please login to comment.
Latest blogs
My Takeaway from Optimizely Opal Agents in Action 2026 - What Agentic AI Means for the Future of Digital Marketing

I would like to share with you what stayed in my head after this amazing virtual event organized by Optimizely. Agents in Action 2026 , a live...

Augusto Davalos | Mar 6, 2026

From Vision to Velocity: Introducing the Optimizely MVP Technical Roundtable

Digital transformation is a two-sided coin. On one side, you have the high-level strategy, the business cases, the customer journeys, and the...

Patrick Lam | Mar 6, 2026

Commerce 14.45.0 is incompatible with CMS 12.34.2 (but that's an easy fix!)

Incompatible is a strong word, but that is to get your attention. This is one of the small thing that can be overlooked, but if you run into it, it...

Quan Mai | Mar 5, 2026

Announcing Stott Security Version 5.0

March 2026 marks the release of Stott Security v5, a significant update to the popular web security add-on for Optimizely CMS 12+, with more than...

Mark Stott | Mar 5, 2026