Position
The position of a widget refers to its location relative to other widgets with the same placement. The following sections describe Brightspot's default positioning logic as well as techniques for overriding that logic.
Default positioning
Within the same Placement (top, bottom, right, dedicated tab), Brightspot by default positions custom widgets in alphabetical order based on the class's fully qualified name. For example, suppose you defined three custom widgets, widgets.AdamsCustomWidget
, widgets.JacksCustomWidget
, and specials.widgets.ZoesCustomWidget
, and all of them appear under the Content Edit Form. By default, Brightspot positions them in alphabetical order as in the following illustration.
Custom positioning
You can override the alphabetical sorting for custom widgets by implementing the method ContentEditWidget#getPosition
and returning a double value. Values with smaller numbers appear closer to the top, and the default value is zero. Positions with the same value are sorted alphabetically by fully qualified class name.
Suppose you assign Zoe's, Adam's, Jack's, and Jill's widgets return values for getPosition
as in the following table.
Widget | Fully Qualified Class Name | getPlacement | getPosition |
---|---|---|---|
Zoe | special.widgets.ZoesCustomWidget | ContentEditWidgetPlacement.BOTTOM | 10.0 |
Adam | widgets.AdamsCustomWidget | ContentEditWidgetPlacement.BOTTOM | 10.0 |
Jack | widgets.JacksCustomWidget | ContentEditWidgetPlacement.BOTTOM | 8.0 |
Jill | widgets.JillsCustomWidget | ContentEditWidgetPlacement.BOTTOM | 9.0 |
Because all the widgets have the same placement, Brightspot lays them out as in the following illustration.

Both Zoe's and Adam's widgets have the same return value for getPosition
, so Brightspot breaks the tie by sorting by fully qualified class name.
Custom positioning with substitution
If you use a custom widget that is imported from another package, that widget may have a result from getPosition
that conflicts with your implementation. Referring to the table Example values for positioning widgets, Zoe's custom widget has a position of 10, but you may want to place her widget first, in front of all the other custom widgets.
You can use Substitutions to incorporate an imported widget into your project and then override the original value for getPosition
.
import com.psddev.cms.tool.ContentEditWidgetPlacement; import com.psddev.cms.tool.ToolPageContext; import com.psddev.dari.db.Substitution; import special.widgets.ZoesCustomWidget; 1 public class ZoesPortedCustomWidget extends ZoesCustomWidget implements Substitution { 2 @Override public double getPosition(ToolPageContext page, Object content, ContentEditWidgetPlacement placement) { 3 return 6.0; } }
Imports the custom widget | |
Declares a ported custom widget | |
Overrides the imported widget's position, now assigning it 6 (compared to the original 10 as listed in the table Example values for positioning widgets). This position value is the lowest of all other custom widgets. |
At run time, the ported custom widget appears first among all other custom widgets under the content edit form.
