2

I want to access for particular information which is contained in event object.

public function init()
{
    parent::init();

    craft()->on('entries.saveEntry', function(Event $event) 
    {

        var_dump($event->params['entry']);
    });
} 

it dumps info (brining a needed part)

     ......
["_preppedContent":"Craft\BaseElementModel":private]=>
  array(1) {
    ["tweet"]=>
    array(23) {
      ["created_at"]=>
      string(30) "Thu Nov 13 09:15:40 +0000 2014"
      ["id"]=>
      float(5.3282410346476E+17)
      ["id_str"]=>
      string(18) "532824103464763392"
      ["text"]=>
      string(115) "'The innovation insight you didn't get from Forbes' great blog by @LydiaRagoonanan @nesta_uk http://t.co/PImPVvWeAv"
      ["source"]=>
      string(63) "Hootsuite"
      ["truncated"]=>
      bool(false)

How can I extract text, id_str information? Thanks

2

I assume both text and id_str are custom fields?

$event->params['entry']

Is an EntryModel, so you should be able to do this:

$entry = $event->params['entry'];
$idString = $entry->id_str;
$text = $entry->text;
2
  • I can't do so, but I found a way $event->params['entry']->getFieldValue('tweet')['text'] Dec 2 '14 at 15:48
  • Oh, you must be using a plugin that populates 'tweet', then.
    – Brad Bell
    Dec 2 '14 at 16:28
-1

It's an array, so:

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

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.