我是 Zend FW 的新手。我希望在名为 Feedparsercontroller's indexAction 的 Controller 中编写一个简单的 feedparser。但我想将解析后的提要输出显示为索引页面上的小部件。我如何将输出/变量数据驱动到我的索引 View ?
下面是我的解析器。
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 ();
}
}
}
}
我想用我的登录实现相同的功能,并注册 Controller 。
最佳答案
也许我没有完全理解你的问题。
但是,这里最好的方法似乎是创建一个单独的 feed Controller ,专门负责与 feed 相关的业务逻辑(检索、消息处理、设置查看等)。
然后,创建一个包含 javascript 代码的部分来调用 feed Controller ,然后输出您想要的小部件。这在一些方面做得很好。
- 它集中了与 Feed 相关的逻辑
- 它允许您将 feed 小部件放置在您想要的任何位置
- 这是一种 SOA 方法,通常是一件好事
希望这有帮助!
关于php - Zend 框架 : Incuding other controllers in index view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6086637/