将无限滚动与表达式引擎相结合
我需要将表达式引擎与 http://www.infinite-scroll.com 结合起来。
我尝试了多种将分页与 jQuery 插件相结合的方法,但找不到成功的方法。
我可以通过将我的条目限制为 2 来让它工作(一点点),这可以实现无限滚动,但是由于某种原因,一旦您点击第 2 页,条目就会重复?例如,我有 6 个条目,一旦我滚动到底部,它会加载接下来的两个条目,但是当我滚动到此页面的底部时,它会重新加载第四个条目,当我滚动到第三个“页面”的底部时它会重新加载第 5 个条目等...所以我有 2 个条目 4、2 个条目 5 等等...
如果我将限制更改为 3(这就是我想要的数量),则无限滚动根本不会运行,任何想法?
有没有人成功地将无限滚动与表达式引擎一起使用。它似乎可以与除表达式引擎之外的所有其他 CMS 系统配合良好。
这是我试图完成它的链接:
这是我的代码:
[removed][removed]
[removed]
$('#content').infinitescroll({
// callback : function () { console.log('using opts.callback'); },
navSelector : "#content .navigation",
nextSelector : "#content a.next",
itemSelector : "#content .post",
debug : false,
dataType : 'html',
// behavior : 'twitter',
// appendCallback : false, // USE FOR PREPENDING
// pathParse : function( pathStr, nextPage ){ return pathStr.replace('2', nextPage ); }
}, function(newElements){
//USE FOR PREPENDING
// $(newElements).css('background-color','#ffef00');
// $(this).prepend(newElements);
//
//END OF PREPENDING
window.console && console.log('context: ',this);
window.console && console.log('returned: ', newElements);
});
[removed]
<div id="content">
{exp:channel:entries channel="blog" limit="2" paginate="bottom"}
<section class="post">
<article>
<h1>{title}</h1>
<h2 class="margin">{entry_date format="%d %M, %Y"}</h2>
{blog_copy}
<ul class="social-icons">
<li><span class="st_facebook_custom" st_title="INC Daily - {title}" st_url="{page_url}"><img src="/inc_daily/images/fb-icon.gif" alt=""/> </span></li>
<li><span class="st_twitter_custom" st_title="INC Daily - {title}" st_url="{page_url}"><img src="/inc_daily/images/twitter-icon.gif" alt=""/> </span></li>
</ul>
</article>
{exp:imgsizer:size src="{blog_image}" width="528" height="356"}
<img src="{sized}" width="{width}" height="{height}" alt="" />
{/exp:imgsizer:size}
</section><!-- END POST -->
{paginate}
<div class="navigation">
<span id="paginationtotal" title="{exp:stats channel='blog'}{total_entries}{/exp:stats}"></span>
{if next_page}<a class="next" href="{auto_path}">Next Page</a>{/if}
</div>
{/paginate}
{/exp:channel:entries}
</div>
I need to combine Expression Engine with http://www.infinite-scroll.com.
I have tried numerous ways of combining pagination with the jQuery plugin but cannot find a successful way of doing so.
I can get it to work (a little) by limiting my entries to 2, this enables the infinite scroll however for some reason once you hit page 2, the entries repeat? For example, I have 6 entries, once I scroll to the bottom, it loads the next two fine but when I scroll to the bottom of this page, it reloads the 4th entry, when I scroll to the bottom of the 3rd ‘page’ it reloads the 5th entry etc… so I have 2 of entry 4, 2 of entry 5 etc etc…
If I change the limit to 3 (which is how many I want), the infinite scroll won’t run at all, any ideas?
Has anyone successfully used Infinite Scroll with Expression Engine. It seems to work fine with EVERY other CMS system but expression engine.
Here is the link I’m trying to accomplish it on:
This is my code:
[removed][removed]
[removed]
$('#content').infinitescroll({
// callback : function () { console.log('using opts.callback'); },
navSelector : "#content .navigation",
nextSelector : "#content a.next",
itemSelector : "#content .post",
debug : false,
dataType : 'html',
// behavior : 'twitter',
// appendCallback : false, // USE FOR PREPENDING
// pathParse : function( pathStr, nextPage ){ return pathStr.replace('2', nextPage ); }
}, function(newElements){
//USE FOR PREPENDING
// $(newElements).css('background-color','#ffef00');
// $(this).prepend(newElements);
//
//END OF PREPENDING
window.console && console.log('context: ',this);
window.console && console.log('returned: ', newElements);
});
[removed]
<div id="content">
{exp:channel:entries channel="blog" limit="2" paginate="bottom"}
<section class="post">
<article>
<h1>{title}</h1>
<h2 class="margin">{entry_date format="%d %M, %Y"}</h2>
{blog_copy}
<ul class="social-icons">
<li><span class="st_facebook_custom" st_title="INC Daily - {title}" st_url="{page_url}"><img src="/inc_daily/images/fb-icon.gif" alt=""/> </span></li>
<li><span class="st_twitter_custom" st_title="INC Daily - {title}" st_url="{page_url}"><img src="/inc_daily/images/twitter-icon.gif" alt=""/> </span></li>
</ul>
</article>
{exp:imgsizer:size src="{blog_image}" width="528" height="356"}
<img src="{sized}" width="{width}" height="{height}" alt="" />
{/exp:imgsizer:size}
</section><!-- END POST -->
{paginate}
<div class="navigation">
<span id="paginationtotal" title="{exp:stats channel='blog'}{total_entries}{/exp:stats}"></span>
{if next_page}<a class="next" href="{auto_path}">Next Page</a>{/if}
</div>
{/paginate}
{/exp:channel:entries}
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不久前,我修改了 Paul Irish 的示例后,它就可以工作了。您可以在这里看到我所做的:
https://github.com/imjared/projects/tree /master/ee_inf_scroll
对于缺乏文档和清晰度表示歉意,希望它有所帮助。
I had it working a while ago after modifying Paul Irish's example. You can see what I did here:
https://github.com/imjared/projects/tree/master/ee_inf_scroll
Apologies for the lack of documentation and clarity, hope it's helpful.