Is it possible to conditionally cancel a shape during a displaying / creating event?

Topics: Core, Writing modules
Developer
Jun 23, 2012 at 9:49 PM
Edited Jun 23, 2012 at 9:51 PM

I'm sure most of us have been there: you're eating a sandwhich, and suddenly you ask yourself: is it possible to prevent a shape from rendering based on a certain condition? Just as if you put "-" or "Nowhere" in placement.info for that particular shape, only this time you want the shape to either render or not based on some application specific condition. For example:

public class SubtitleFieldShapeAlteration : ShapeDisplayEvents {

        public override void Displaying(ShapeDisplayingContext context) {
            if (context.Shape.ContentField.Name == "MyFieldName")
            {
                
                if (aCertainCondition == True) {
                    // Somehow instruct the shape or the display manager to *not* render the shape
                }
            }
        }

    }

Now I could easily add some code to the shape template to not render a thing, but since that template can be overridden in a theme, I don't want to have the theme developer to duplicate my logic that decides wether or not the shape should be displayed.

I should add that I do not create this shape myself: it's a shape created by some TextFieldDriver.

 

Coordinator
Jun 26, 2012 at 6:31 AM

Sure, send it to a zone that never gets rendered for example.

Developer
Jun 26, 2012 at 12:03 PM

Oh yes, thanks! That's why I didn't think of it myself: too simple a solution :)