PHP generating rss feed

Discussion in 'PHP' started by cp431, Jan 23, 2011.

  1. #1
    Hi all, I am using PHPfox on my website and I would like to change a feed to show one specific users activity. Below is the current code that generates the RSS, I essentially want to only show post from user "Candice". I have tried adding if statements with no luck...Could someone help with the formatting?

    
    list($iCnt, $aRows) = Phpfox::getService('blog')->get(array('AND blog.is_approved = 1 AND blog.privacy = 1 AND blog.post_status = 1'), 'blog.time_stamp DESC', 0, Phpfox::getParam('rss.total_rss_display'));
    foreach ($aRows as $iKey => $aRow)
    {
    	$aRows[$iKey]['description'] = $aRow['text'];
    	$aRows[$iKey]['link'] = Phpfox::itemUrl('blog', $aRow['title_url'], $aRow['user_name']);
    	$aRows[$iKey]['creator'] = $aRow['full_name'];
    }
    
    PHP:
    Thanks!
     
    cp431, Jan 23, 2011 IP
  2. domainwink

    domainwink Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    list($iCnt, $aRows) = Phpfox::getService('blog')->get(array('AND blog.is_approved = 1 AND blog.privacy = 1 AND blog.post_status = 1'), 'blog.time_stamp DESC', 0, Phpfox::getParam('rss.total_rss_display'));
    foreach ($aRows as $iKey => $aRow)
    {
        if($aRow['full_name'] != 'NAME_HERE') continue;
        $aRows[$iKey]['description'] = $aRow['text'];
        $aRows[$iKey]['link'] = Phpfox::itemUrl('blog', $aRow['title_url'], $aRow['user_name']);
        $aRows[$iKey]['creator'] = $aRow['full_name'];
    }
    
    PHP:
     
    domainwink, Jan 23, 2011 IP
  3. cp431

    cp431 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Perfect...Thanks!
     
    cp431, Jan 24, 2011 IP
  4. cp431

    cp431 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Actually, I spoke to soon...The feed is still displaying updates from all users rather than just the one I enter in "NAME HERE". Any ideas?

    Thanks
     
    cp431, Jan 24, 2011 IP
  5. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #5
    he did it wrong :D
    list($iCnt, $aRows) = Phpfox::getService('blog')->get(array('AND blog.is_approved = 1 AND blog.privacy = 1 AND blog.post_status = 1'), 'blog.time_stamp DESC', 0, Phpfox::getParam('rss.total_rss_display'));
    foreach ($aRows as $iKey => $aRow)
    {
        if($aRow['full_name'] != 'NAME_HERE') break;
        $aRows[$iKey]['description'] = $aRow['text'];
        $aRows[$iKey]['link'] = Phpfox::itemUrl('blog', $aRow['title_url'], $aRow['user_name']);
        $aRows[$iKey]['creator'] = $aRow['full_name'];
    }
    
    PHP:
    I am not sure if it will work, but you could try it ;)
     
    G3n3s!s, Jan 24, 2011 IP
  6. Alex Roxon

    Alex Roxon Active Member

    Messages:
    424
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    80
    #6
    The above won't work. The second it doesn't get the name you want, it's just going to break the loop. Continue would have been better.

    Wouldn't it be better to add the condition to the where clause in your query? I've never used PHPFox, so I'm not too sure how it works, however I'm assuming you could just do something like this:

    list($iCnt, $aRows) = Phpfox::getService('blog')->get(array('AND blog.is_approved = 1 AND blog.privacy = 1 AND blog.post_status = 1 AND blog.full_name = "NAME HERE"'), 'blog.time_stamp DESC', 0, Phpfox::getParam('rss.total_rss_display'));
    PHP:
     
    Alex Roxon, Jan 24, 2011 IP
  7. cp431

    cp431 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks for the replies the last attempt appears to be filtering the results but it is filtering down to zero entries...Any other ideas?

    Thanks!
     
    cp431, Jan 24, 2011 IP