Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2010-08-15 15:46:03
- fhd
- Member
- Registered: 2009-11-01
- Posts: 13
List only a few articles, display more when scrolling
Hi,
I’m surprised that I couldn’t find anything on this topic, but this may due to me not knowing the proper terminology for what I want to archive.
I’ve used Textpattern for a while know and I have numerous articles on my blog. This is starting to have a serious impact on my page’s load time, since all articles are loaded. What I want is to have textpattern load only a few articles (~3) and load more when the user scrolls down. This is how it works on this blog. I’d also be happy with a “more articles” link/button as they use it on Slashdot.
Is there a plugin for that?
Offline
Re: List only a few articles, display more when scrolling
That’s relatively simple to do and it doesn’t necessarily have to be a plugin. Instead you only need that type of JavaScript snippet the blog you linked uses. Basically the script is just a normal Ajax call that is invoked when visitor is close to the page end. You can look at the page’s source and see yourself. The blog also uses jQuery, which ships also with Textpattern.
After that you just need a page that delivers the articles. On that page you could put something like for example (which would work with the JS the blog has):
<txp:article_custom limit="10" offset='<txp:php> echo("startindex"); </txp:php>' />
And that’s it. Then just make a Ajax call to the page where the code is and reinvoke the code everytime visitor is some pixels from the page end.
Or, as a second option, you could use script like Infinite Scroll. It’s a jQuery plugin. With the plugin you can auto-load more content (or next pages) from your standard TXP pagination links, which means that you don’t even need to use page to deliver articles, but just tell the plugin where your Prev/Next links are and it gets the next page for you.
Last edited by Gocom (2010-08-15 16:18:51)
Offline
#3 2010-08-16 08:10:47
- fhd
- Member
- Registered: 2009-11-01
- Posts: 13
Re: List only a few articles, display more when scrolling
After you mentioned TXP pagination links, I did some research and found that it’s the feature I was looking for: <txp:newer> and <txp:older>.
The user has to click on the links, but it’s nonetheless way better than having to load all the articles. I will look at Infinite Scroll to create my desired behaviour.
Thank you!
Offline