Yii processOutput only for certain action

Hi all,

I need to know if there’s a way to use processoutput for only certain action. Here’s my current code to do this:

public function processOutput($output)


    // will only run for the result action

    if('result' != $this->getAction()->getId())

        return $output;


But I think it’s bad because one day we’ll need this processOutput for the other action too. I’m thinking to use filter, but reading the documentation I believe I can only do that with the object filter, not the inline filter because I want to run the filter after the action finished. Is my assumption correct?

And if that is the case, say I write the Filter Class, then when I need the output of action to be processed, how do I access it, given that I use the thrid argument in render function stated in the documentation?

Thanks before.

I’m interested in which context you will use this since I’ve only seen processOutput being called from a renderPartial method so far.

I’m making a search engine, and I need to highlight the search result for user’s query. Is there a better way to do it? I’m using [font=“Courier New”]Zend_Search_Lucene[/font], and if I understand correctly, [font=“Courier New”]Zend_Search_Lucene_Search_Query::highlightMatches[/font] only accepts HTML input. That’s why I need to do processOutput, since only then I can get the HTML result of my database query.


What about ‘returning’ the render() instead of ‘echoing’ to get generated html?

public function processOutput($data)


    // public string render(string $view, array $data=NULL, boolean $return=false)

    $output = $this->render('search', $data, true); // set third argument to true.

    // process highlight...

    return $output;


Then call it from the action…

See last part of render() method.



      return $output;


      echo $output;