2008年10月18日星期六

Re: [fw-webservices] ZEND Feed and me trying to paginate it

Try doing:

$feed = new
Zend_Feed_Atom('http://wildoakrestaurant.blogspot.com/atom.xml');
$feedLimit = 5;


$f = new LimitIterator($feed, $feedLimit);

$f->seek(5) should return the last item since your feed limit is 5.  I will try and full test the example a little later when I can get to my computer.

On Sat, Oct 18, 2008 at 12:45 AM, firecall <alex@diversitygroup.com.au> wrote:

Hi Corey,

Ok thanks. But I'm not sure I follow correctly how to use it.

I'm trying this - code fragment:

    $feed = new
Zend_Feed_Atom('http://wildoakrestaurant.blogspot.com/atom.xml');

                       $f = new LimitIterator($feed);
                       $f->seek(5);

                       $blog = "";
                       foreach ($f as $entry) {

                               $blog .= "<ul class=\"blogEntry\">";
                               $blog .= "<li class=\"blogTitle\">" . $entry->title() .  "</li>";
                           $blog .= "<li class=\"blogTime\">" . date("D jS F Y",
strtotime($entry->published())) . "</li>";
                               $blog .= "<li class=\"blogContent\">" . $entry->content('html') .
"</li>";
                               $blog .= "<li class=\"blogAuthor\">Author: " . $entry->author->name() .
"</li>";
                               $blog .= "</ul>";
                       }


Where I thought the LimitIterator Class could be used with the seek method
to find a certain point. But it doesnt seem to do that.

It's a tad outside of my understanding at the moment, which is why I'm
struggling a bit.

Simple things take me days sometimes :-)

Thanks for any help.

fc


kwylez wrote:
>
> I use LimitIterator (SPL function -
> http://www.php.net/~helly/php/ext/spl/classLimitIterator.html) for the
> exact
> use case you are describing.
>
>         <ul>
>           <?
>           foreach (new
> LimitIterator($rssfeed->getFirstInstanceFeedInstance(), 0,
> RSS::RSS_ITEM_LIMIT) as $item):
>           ?>
>           <li> "<?=$item- link();?>" target="_blank"
> title="<?=$item->title()?>"><?=$item->title();?> </li>
>           <?
>           endforeach;
>           ?>
>         </ul>
>
> On Fri, Oct 17, 2008 at 9:28 PM, firecall
> <alex@diversitygroup.com.au>wrote:
>
>>
>> Hi,
>>
>> I'd thought that ZEND Feed returned an Array object?
>>
>> But in my wanting to paginate the output id thought I could array_slice
>> it
>> to get the sequence of entries I want but that doesnt work on the feed
>> object.
>>
>> I'd cant seem to do something like: $output = array_slice(Sfeed, 5)
>>
>>
>> So really what I'm asking is: How would I go about paginating a ZEND Feed
>> object?
>>
>> Or how could I manipulate a ZEND_Feed object as an array?
>>
>>
>> I can output and format the ZEND_Feed object, it's just traversing it and
>> getting only the entries I want thats confusing me.
>>
>> My other option is to just use something like http://simplepie.org, but I
>> have the whole ZEND MVC thing working so wanted to stick withing the ZEND
>> toolset if I could.
>>
>> thanks, firecall
>> --
>> View this message in context:
>> http://www.nabble.com/ZEND-Feed-and-me-trying-to-paginate-it-tp20043583p20043583.html
>> Sent from the Zend Web Services mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cory Wiles
> kwylez@gmail.com
> http://www.corywiles.com
> http://www.400mtogo.com
>
>

--
View this message in context: http://www.nabble.com/ZEND-Feed-and-me-trying-to-paginate-it-tp20043583p20044358.html
Sent from the Zend Web Services mailing list archive at Nabble.com.




--
Cory Wiles
kwylez@gmail.com
http://www.corywiles.com
http://www.400mtogo.com

没有评论: