开发者

How can I implement JQuery Pagination into a custom script?

开发者 https://www.devze.com 2022-12-10 17:48 出处:网络
I am using a bespoke Jquery/PHP gallery script which pulls images from a Flickr feed. I have tried to implement the JQuery pagination plugin, to no avail.

I am using a bespoke Jquery/PHP gallery script which pulls images from a Flickr feed. I have tried to implement the JQuery pagination plugin, to no avail.

Here is the code...

<?php

require_once('php/simplepie.inc');

$feed = new Simplepie('http://api.flickr.com/services/feeds /photos_public.gne?id=44262300@N06&lang=en-us&format=rss_200');

   $feed->handle_content_type();



function image_f开发者_StackOverflow中文版rom_description($data) {

preg_match_all('/<img src="([^"]*)"([^>]*)>/i', $data, $matches);

return $matches[1][0];

}



function select_image($img, $size) {

$img = explode('/', $img);

$filename = array_pop($img);



$s = array(

    '_s.', // square

    '_t.', // thumb

    '_m.', // small

    '.',   // medium

    '_b.'  // large

  );



   $img[] = preg_replace('/(_(s|t|m|b))?\./i', $s[$size], $filename);

   return implode('/', $img);

}

?>


<script type="text/javascript">
$(function(){
$("#images div").quickpaginate({ perpage: 4, showcounter: false, pager :  $("#image_counter") });
});

</script>




  <div class="album-wrapper" id="images">

        <?php foreach ($feed->get_items() as $item): ?>

            <div class="photo">

                <?php

                    if ($enclosure = $item->get_enclosure()) {



                        $img = image_from_description($item->get_description());

                        $full_url = select_image($img, 4);

                        $thumb_url = select_image($img, 0);

                        echo '<a href="' . $full_url . '" class="thickbox" title="' . $enclosure->get_title() . '"><img id="photo_' . $i . '" src="' . $thumb_url . '" /></a>'."\n";

                    }

                ?>


            </div>

        <?php endforeach; ?>
    </div>
    <div id="image_counter"></div>

Can anyone see what I have missed or I am doing wrong?

Thanks,

Dan


Have you tried trying to isolate the area where the error might be located? Can you figure it out if it is in the PHP-side of your code or on the JavaScript side?

In any case, I've had success using the jQuery pager companion plugin for the Tablesorter plugin. It doesn't work very well for very long lists of data, however.

0

精彩评论

暂无评论...
验证码 换一张
取 消