Search code examples
phpzend-frameworkzend-feed

Zend Framework : Incuding other controllers in index view


I am new to Zend FW. I am looking to write a simple feedparser in a controller named Feedparsercontroller's indexAction. but i want to display the parsed feed output as a widget on my index page. how can i drive the output/ variable data to my indexview?

The below is my parser.

class FeedparserController extends Zend_Controller_Action {

public function init() {
    /* Initialize action controller here */
}

public function indexAction() {

    $feedUrl = 'http://feeds.feedburner.com/ZendScreencastsVideoTutorialsAboutTheZendPhpFrameworkForDesktop';
    $feed = Zend_Feed_Reader::import ( $feedUrl );

    $this->view->gettingStarted = array ();
    foreach ( $feed as $entry ) {
        if (array_search ( 'Getting Started', $entry->getCategories ()->getValues () )) {
            $this->view->gettingStarted [$entry->getLink ()] = $entry->getTitle ();
        }
    }
}

}

i want to implement the same with my login , register controllers as well.


Solution

  • Perhaps I'm not understanding your question fully.

    But, it seems the best approach here would be to create a separate feed controller that is solely responsible for the business logic associated with feeds (retrieving, massaging, setting to view, etc).

    Then, create a partial which contains javascript code to call the feed controller, which then outputs the widget you're desiring. This does a few things very well.

    1. It centralizes feed-related logic
    2. It allows you to place the feed widget wherever you want
    3. It is a SOA approach which is generally a good thing

    Hope this helps!