get(attributeName)

Retrieves a custom attribute of a Widget instance.

Passing an invalid attribute name returns null.

Params

  • attributeName (String) – The name of the attribute.

Returns

The value of the attribute. Its type can be Date, Number, Binary, Link, Obj,Widget, String, Array<Link>, Array<Obj>, Array<Widget>, or Array<String>. Its type can also be null in case the value is empty, or if the attribute does not exist.

Example

Retrieve the value of a widget's attribute, depending on the widget type:

Copy
widget = Scrivito.Obj.getByPermalink("blog").get("body")[0];
widget.objClass();
// => "ButtonWidget"
widget.get("alignment");
// => "center"