I was looking for a way to show all fields/properties of a given object, and came across this useful tidbit: How to display all fields belonging to current entry?
I'm new to Craft/Twig and didn't actually know what type of object I'm trying to output properties of. I'm not sure when I output the object with {{ mysteryObject }}
it outputs a number. That doesn't seem useful.
When I do the loop like in the question I referenced above like:
{% for prop in mysteryObject.getFields() %}
{# get the field Model from the fieldId #}
{% set field = craft.fields.getFieldById(mysteryObject.fieldId) %}
{# print the field handle and the field content #}
{{ field.handle }}
:
{{ entry.getContent()[field.handle] }}
{% endfor %}
I get the error:
Calling unknown method: craft\elements\MatrixBlock::getFields()
Cool, so now I know my object is a MatrixBlock
, but this makes me wonder how I would go about inspecting the properties of just any object, like you can in JavaScript, without knowing what the object is.