1

As of Craft 2.2 build 2579 / 2581 I get an error upon save for entires in a section that uses postDate in the URL and in the {slug}

CException Craft\MatrixBlockModel and its behaviors do not have a method or closure named "postDate".

Removing postDate from slug didn't eliminate error. Also noticed that system wanted to change postDate in slug when editing older entries.

**Any possible work arounds for this? **

--------------------------------------------------------


/www/Sites/craft.dev/craft/app/framework/base/CComponent.php(266)

266 throw new CException(Yii::t('yii','{class} and its behaviors do not have a method or closure named "{name}".',

Stack Trace

#0  
+  /www/Sites/craft.dev/craft/app/models/BaseModel.php(124): CComponent->__call("postDate", array())
#1  
 unknown(0): Craft\BaseModel->__call("postDate", array())
#2  
 unknown(0): Craft\MatrixBlockModel->postDate()
#3  
+  /www/Sites/craft.dev/craft/app/vendor/twig/twig/lib/Twig/Template.php(461): call_user_func_array(array(Craft\MatrixBlockModel, "postDate"), array())
#4  
+  /www/Sites/craft.dev/craft/app/etc/templating/BaseTemplate.php(41): Twig_Template->getAttribute(Craft\MatrixBlockModel, "postDate", array(), "any", ...)
#5  
+  /www/Sites/craft.dev/craft/storage/runtime/compiled_templates/30/9d/6b553941d52d3cfbc7a301dc2160dfce824fa19b6538fb3b0819c38d9211.php(19): Craft\BaseTemplate->getAttribute(Craft\MatrixBlockModel, "postDate")
#6  
+  /www/Sites/craft.dev/craft/app/vendor/twig/twig/lib/Twig/Template.php(279): __TwigTemplate_309d6b553941d52d3cfbc7a301dc2160dfce824fa19b6538fb3b0819c38d9211->doDisplay(array("object" => Craft\MatrixBlockModel, "craft" => Craft\CraftVariable, "blx" => Craft\CraftVariable, "now" => Craft\DateTime, ...), array())
#7  
+  /www/Sites/craft.dev/craft/app/vendor/twig/twig/lib/Twig/Template.php(253): Twig_Template->displayWithErrorHandling(array("object" => Craft\MatrixBlockModel, "craft" => Craft\CraftVariable, "blx" => Craft\CraftVariable, "now" => Craft\DateTime, ...), array())
#8  
+  /www/Sites/craft.dev/craft/app/vendor/twig/twig/lib/Twig/Template.php(264): Twig_Template->display(array("object" => Craft\MatrixBlockModel))
#9  
+  /www/Sites/craft.dev/craft/app/services/TemplatesService.php(309): Twig_Template->render(array("object" => Craft\MatrixBlockModel))
#10 
+  /www/Sites/craft.dev/craft/app/fieldtypes/AssetsFieldType.php(407): Craft\TemplatesService->renderObjectTemplate("{postDate.year}/{postDate.month}", Craft\MatrixBlockModel)
#11 
+  /www/Sites/craft.dev/craft/app/fieldtypes/AssetsFieldType.php(203): Craft\AssetsFieldType->_resolveSourcePathToFolderId("1", "{postDate.year}/{postDate.month}/")
#12 
+  /www/Sites/craft.dev/craft/app/services/ElementsService.php(1197): Craft\AssetsFieldType->onAfterElementSave()
#13 
+  /www/Sites/craft.dev/craft/app/services/MatrixService.php(701): Craft\ElementsService->saveElement(Craft\MatrixBlockModel, false)
#14 
+  /www/Sites/craft.dev/craft/app/services/MatrixService.php(802): Craft\MatrixService->saveBlock(Craft\MatrixBlockModel, false)
#15 
+  /www/Sites/craft.dev/craft/app/fieldtypes/MatrixFieldType.php(467): Craft\MatrixService->saveField(Craft\MatrixFieldType)
#16 
+  /www/Sites/craft.dev/craft/app/services/ElementsService.php(1197): Craft\MatrixFieldType->onAfterElementSave()
#17 
+  /www/Sites/craft.dev/craft/app/services/EntriesService.php(167): Craft\ElementsService->saveElement(Craft\EntryModel)
#18 
+  /www/Sites/craft.dev/craft/app/controllers/EntriesController.php(479): Craft\EntriesService->saveEntry(Craft\EntryModel)
#19 
+  /www/Sites/craft.dev/craft/app/framework/web/actions/CInlineAction.php(49): Craft\EntriesController->actionSaveEntry()
#20 
+  /www/Sites/craft.dev/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(array("p" => "admin/entries/daily/56-daily-edition-for-2014-5-19"))
#21 
+  /www/Sites/craft.dev/craft/app/framework/web/CController.php(286): CController->runAction(CInlineAction)
#22 
+  /www/Sites/craft.dev/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(CInlineAction, null)
#23 
+  /www/Sites/craft.dev/craft/app/framework/web/CWebApplication.php(282): CController->run("saveEntry")
#24 
+  /www/Sites/craft.dev/craft/app/etc/web/WebApp.php(899): CWebApplication->runController("entries/saveEntry")
#25 
+  /www/Sites/craft.dev/craft/app/etc/web/WebApp.php(272): Craft\WebApp->_processActionRequest()
#26 
+  /www/Sites/craft.dev/craft/app/framework/base/CApplication.php(180): Craft\WebApp->processRequest()
#27 
+  /www/Sites/craft.dev/craft/app/index.php(35): CApplication->run()
#28 
–  /Users/jball/Sites/craft.dev/public/index.php(14): require_once("/www/Sites/craft.dev/craft/app/index.php")
3

Looks like maybe you have an Assets field within a Matrix field, which has the dynamic subpath set to:

{postDate.year}/{postDate.month}/

But as the error suggests, Matrix blocks don’t have post dates. They have an owner, though, and that owner will have a post date, if it's an entry. So you should use this instead:

{owner.postDate.year}/{owner.postDate.month}/

or:

{owner.postDate|date('Y/n')}/
  • Yep, you nailed it Brandon. Using "owner." in the default dynamic subpath fixed the issue. The dynamic subpath is such an awesome feature for clients finding their assets & keeping them organized. Thanks & have a great weekend! – Moto_Nomad Sep 5 '14 at 23:04

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.