Skip to main content
added 151 characters in body
Source Link
Brad Bell
  • 67.6k
  • 6
  • 75
  • 145

Completely untested, but a possibility would be to define your content attribute like so:

return array(AttributeType::Mixed, 'model' => 'MyPluginContentModel');

MyPluginContentModel would have every possible value that you would want to expose to your template ('id', 'obj', 'etc') defined as an attribute.

When Craft pulls the JSON from the database, it should decode it and populate your model with any matching attributes it finds.

That gets returned to your template and you can access it via {{ value.id }}.

Completely untested, but a possibility would be to define your content attribute like so:

return array(AttributeType::Mixed, 'model' => 'MyPluginContentModel');

When Craft pulls the JSON from the database, it should decode it and populate your model with any matching attributes it finds.

That gets returned to your template and you can access it via {{ value.id }}.

Completely untested, but a possibility would be to define your content attribute like so:

return array(AttributeType::Mixed, 'model' => 'MyPluginContentModel');

MyPluginContentModel would have every possible value that you would want to expose to your template ('id', 'obj', 'etc') defined as an attribute.

When Craft pulls the JSON from the database, it should decode it and populate your model with any matching attributes it finds.

That gets returned to your template and you can access it via {{ value.id }}.

Source Link
Brad Bell
  • 67.6k
  • 6
  • 75
  • 145

Completely untested, but a possibility would be to define your content attribute like so:

return array(AttributeType::Mixed, 'model' => 'MyPluginContentModel');

When Craft pulls the JSON from the database, it should decode it and populate your model with any matching attributes it finds.

That gets returned to your template and you can access it via {{ value.id }}.