Take the 2-minute tour ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

After doing some experimentation in looping through MatrixBlockModel, it seems that even though each block has a dateUpdated property, this value is never unique to each block, but is shared between all blocks in the Entry.

{% set timeLimit = now | date_modify("-2 min") %}
{% for block in entry.blocks %}
  {% if block.dateUpdated >= timeLimit %}

    {{ block.dateUpdated | date(dtFilter) }}

  {% endif %}
{% endfor %}

If the entry has 6 blocks, and I update one of those blocks and save, the same date will output 6 times for about 2 minutes, then nothing will output.

Can anybody confirm this?

share|improve this question

1 Answer 1

Yes I can confirm, currently the dateUpdated property returns the same datetime object for every block model. It's actually the save date of the entry (entry.dateUpdated) that is saved to the craft_matrixblocks table in the DB.

Can't say if it's intended to work like this though.

share|improve this answer
    
Thanks for confirming @carlcs. If this is the intended behavior, its a bit of a bummer because I have a use case (checking for recently-updated matrix blocks via a javascript JSON request) that is far more difficult, maybe even impossible, without a unique updated date time for each block. It's also inconsistent, because each block does have a unique date_created property. –  cmal Aug 23 at 19:36
    
@cmal the (shared) property is probably only saved to make this work: block.dateUpdated. But actually that wouldn't be necessary because you could also do: block.owner.dateUpdated. –  carlcs Aug 28 at 7:19
    
I did a feature request for this on g+. –  carlcs Aug 28 at 7:19
    
Thank you @carlcs –  cmal Aug 28 at 15:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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