I am performing a query from within a plugin like so:

$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section = $journeyTitle;
$response = $criteria->find();
$attributes = $response[0]->getContent()->getAttributes();

The dump gives me the following:

array(7) {
  string(1) "3"
  string(1) "3"
  string(5) "en_us"
  string(7) "Armenia"
  string(12) "fdsfsdfdsfsd"

Has anyone ever used Super Table Before, and know why this would be showing up null? I would REALLY like to use this on my project, but am not really sure on how to proceed with this.

For reference, here is a screenshot of the entry that you see outputted within the dump: enter image description here

  • Might be good to mention that this is for Craft 2.6.3004, not the Craft 3 version of the plugin. – Dan Zuzevich Feb 28 '18 at 16:52
  • I noticed the same issue today with the Craft 3 Version and fixed that issue in the code. I'm not sure if this is worth an answer so I'll leave it as a comment. I noticed some really strange bugs in this plugin overall so I fixed them and now we use a custom version of this plugin for future projects. I suggest you to do the same or use an other plugin/create your own – Robin Schambach Feb 28 '18 at 17:06
  • oh dear lord. Was it a quick fix for that to not show up null, or did it take some significant reworking? The project I am working on would greatly be improved workflow wise if I could get this to work. I don't mind looking at the code to try to fix it myself. – Dan Zuzevich Feb 28 '18 at 17:11
  • 1
    @RobinSchambach I'd be interested to know what your issues where and if we should fix them for the greater community to benefit. – crawf Feb 28 '18 at 20:43
  • @crawf I'm so sorry I messed it up. Unfortunately I thought this question was about supercool table but it's only about supertable. I wasn't talking about your plugin but from another that throws exceptions when you even try to save an entry. – Robin Schambach Mar 1 '18 at 7:17

The reason the attribute for your Super Table is null is because the field is an element, which doesn't have 'simple' content. You'll find this is the exact same case for any other element like an Entries field, or a Matrix field.

I believe the reason for this is that this simply fetches the content from the actual craft_content table. Being complex (relational) data, there's technically nothing in the content table. Getting the content is a little more complex.

In the case of Super Table (and other elements), when querying the field's content on an attached element, you'll get an ElementCriteriaModel (for Craft 2) returned, which allows you to do all sorts of things when outputting the content of a Super Table (limit, order, etc).

To illustrate, you can do:


Which will output the ElementCriteriaModel, which will be not overly useful for actual content output. In addition, you'll want to call find() on the criteria (just like you're doing above in your code to fetch the entries) to return an array of SuperTable_BlockModel's.

$blocks = $response[0]->lifeBeforeColumnOne->find();

foreach ($blocks as $block) {

You can then output the content by targeting the inner fields'.

You might also find this slightly related conversation useful - Getting all content, including Matrix fields from an EntryModel

There's also an example of this sort of functionality on the docs - https://verbb.io/craft-plugins/super-table/docs/guides/developer-examples#fetching-content-from-a-super-table-field

| improve this answer | |
  • Thanks for the clear and concise reply. I'm glad I will be able to use the plugin for my project still. Basically this setup is going to grow to about four super table fields (column one, column two, column three, column four) with the exact same inner setup. Ill mark this as correct, as it answers my question about why its null. Cheers. – Dan Zuzevich Feb 28 '18 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.