2

I'm listening on an entries save event with:

craft()->on('entries.saveEntry', function(Event $event) {
  //$event->params['entry']); -> passes to function 
});

How can I assess assets that are also part of that saved entry?

$event->params['entry']->getContent()->{fieldname} doesn't give me the array with information I was hoping for.

1

This gives you an EntryModel:

$entryModel = $event->params['entry'];

This will give you an array of AssetFileModels:

$assetFileModels = $entryModel->myAssetFieldHandle

You can loop through them like so:

foreach ($assetFileModels as $assetFileModel)
{
    $url = $assetFileModel->getUrl();
}
-1

What about $event->params['entry']->{fieldname}

Wouldn't that be enough?

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.