DanielHardy Posted March 31, 2009 Share Posted March 31, 2009 Hi I have the following controller that helps me to be able to create, read, update and delete records (CRUD) I am trying to create my own RSS feed based upon the generated data. Here is my Controller code <?php class ForumController extends Zend_Controller_Action { function indexAction() { $this->view->title = "My Forums"; $forums = new Forums(); $this->view->forums = $forums->fetchAll(); } public function searchAction() { } // application/controllers/GuestbookController.php public function feedAction() { // Change layout to blank.phtml (empty file) $this->_helper->layout->setLayout('blank'); // Set feed values $array['title'] = 'Guestbook feed'; $array['link'] = 'http://www.somewhere.com/'; $array['description'] = 'This is guestbook feed'; $array['charset'] = 'utf-8'; // You need to change this line to read $array['charset'] = 'utf-8'; (Note the change to the 'utf8' part) // Loop through db records and add feed items to array $forums = new Forums(); $model = $this->_getForm(); foreach($this->forums as $forum) { $array['entries'][] = array( 'title' => $row->email = $form->getValue['email'], 'link' => $row->title = $form->getValue['title'], 'description' => $row->comment = $form->getValue['comment'] ); } // Import rss feed from array $feed = Zend_Feed::importArray($array, 'rss'); // Send http headers and dump the feed $feed->send(); } function addAction() { $this->view->title = "Add New Album"; $form = new ForumForm(); $form->submit->setLabel('Add'); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $forums = new Forums(); $row = $forums->createRow(); $row->email = $form->getValue('email'); $row->title = $form->getValue('title'); $row->comment = $form->getValue('comment'); $row->save(); $this->_redirect('/forum'); } else { $form->populate($formData); } } } function editAction() { $this->view->title = "Edit Album"; $form = new ForumForm(); $form->submit->setLabel('Save'); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $forums = new Forums(); $id = (int)$form->getValue('id'); $row = $forums->fetchRow('id='.$id); $row->email = $form->getValue('email'); $row->title = $form->getValue('title'); $row->comment = $form->getValue('comment'); $row->save(); $this->_redirect('/forum'); } else { $form->populate($formData); } } else { // album id is expected in $params['id'] $id = (int)$this->_request->getParam('id', 0); if ($id > 0) { $forums = new Forums(); $forum = $forums->fetchRow('id='.$id); $form->populate($forum->toArray()); } } } function deleteAction() { $this->view->title = "Delete Album"; if ($this->_request->isPost()) { $id = (int)$this->_request->getPost('id'); $del = $this->_request->getPost('del'); if ($del == 'Yes' && $id > 0) { $forums = new Forums(); $where = 'id = ' . $id; $forums->delete($where); } $this->_redirect('/forum'); } else { $id = (int)$this->_request->getParam('id'); if ($id > 0) { $forums = new Forums(); $this->view->forum = $forums->fetchRow('id='.$id); } } } } Please notice the feed action. When it runs and i browse to my feed page I am just shown a blank page. In that the code is running fine but im guessing it is not finding my form data. Please any suggestion I have been scratching my head over this for weeks. And just incase my view is simply : <? echo $this->feedxml; Thanks in advance Dan Link to comment https://forums.phpfreaks.com/topic/151962-producing-own-web-feed/ Share on other sites More sharing options...
RichardRotterdam Posted March 31, 2009 Share Posted March 31, 2009 Since you are using Zend Framework have you tried or are you using the Zend_Feed class? http://framework.zend.com/manual/en/zend.feed.html Link to comment https://forums.phpfreaks.com/topic/151962-producing-own-web-feed/#findComment-798049 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.