2011-12-19 20 views
0

我安裝了插件,找不到任何告訴我它是如何工作的以及如何使用它。 我有homeSuccess.php到位的圖標和一個空的onClick事件我需要幫助應用sfFeed2Plugin

:在動作類

function gotoFeed(id) 
{ 

    console.log("testing");  
    //must redirect to feeds page?? 
} 

<input class='submit_img' type="image" src="/images/rainbow/feed-icon-14x14.png" value="Feed" alt="Feed" onClick="gotoFeed(this.value,<?php echo $usr_profile->getId();?>)"> 

gotoFeed JS在homeSuccess.php

public function executeFeed(sfWebRequest $request) 
{ 
    $profile_id = $this->getUser()->getAttribute('profile_id','zero');  
} 

有人可以幫忙嗎? 感謝

回答

0

您可以在此鏈接sfFeed2Plugin找到完整的教程,只需點擊選項卡Readme

UPDATE

我使用這個插件在我的動作類像這樣的動作:

public function executeFeedRss(sfWebRequest $request) 
    { 
    $feed = new sfRss201Feed(); 

    $feed->setTitle('MySite'); 
    $feed->setLink($this->generateUrl('@homepage')); 

    $c = new Criteria; 
    $c->addDescendingOrderByColumn(PostPeer::CREATED_AT); 
    $c->setLimit(10); 
    $Posts = PostPeer::doSelect($c); 

    foreach ($Posts as $post) 
    { 
     $item = new sfFeedItem(); 
     $item->setTitle($post->getTitle()); 

     // according to routing rule 
     $item->setLink($this->generateUrl('@posts', array('id'=>$post->getId()))); 

     $item->setPubdate($post->getCreatedAt('U')); 
     $item->setUniqueId($post->getSlug()); 
     $item->setDescription($post->getBody()); 

     $feed->addItem($item); 
    }  
    $this->feed = $feed; 
    } 

and this code inside the template feedRssSuccess.php

<?php decorate_with(false) ?> 
<?php echo $feed->asXml(ESC_RAW) ?> 

最後,我簡單地通過一個模板鏈接到了我的佈局中的這個動作,當然在pageSuccess.php中也是一樣的。

我希望這可以幫助你。

+0

謝謝我有插件,我正在閱讀自述文件,但我有一個自己寫的rainbowcodePlugin的現有應用程序,並且想要使用我現有的表格合併Feed插件... Feed插件是圍繞其他兩個表構建的。我如何讓Feed插件爲我工作?謝謝 – 2011-12-20 11:18:27

+0

任何人都可以幫助我嗎?謝謝 – 2012-01-03 10:58:20

+0

我發佈了我的代碼片段...想出來的聲音...如果你的feed插件是圍繞2個其他表建立的,爲什麼你不能建立一個標準/查詢並替換'$ c = new Criteria; $ c-> addDescendingOrderByColumn(PostPeer :: CREATED_AT); $ c-> setLimit(10); $ Posts = PostPeer :: doSelect($ c);'也替換路由規則,所以使用這段代碼...也許我誤解了你的問題。 – macgyver 2012-01-03 11:15:08