Jump to content

Previous and next post


vxda
 Share

Recommended Posts

Hi, im making a website with alot of articles, my structure looks like this

NEWS

     CATEGORY

               article item

     CATEGORY
               article item

     CATEGORY

               article item

     CATEGORY

               article item

     CATEGORY

On home page im listing all articles from all categories - 25 articles per page.

Im opening them in Fancybox
Insite article i have next and previous buttons, on click im loading content of article via ajax, replacing content in fancybox. and i change history via history api for seo reasons.

My question is:

Is there a way to make next and prev buttons change thru articles but listed on my home page (included next pages) instead of picking next or prev from category the article is nested in ?

Would be grateful for some tips on that.

Cheers

  • Like 1
Link to comment
Share on other sites

Something like?:

//populate a PageArray
$articleList = $pages->find("template=article, limit=25")

//next
$page->next($articleList)

//prev
$page->prev($articleList)

This assumes your articles have their own template. You can put more options, like sort, in the page selector. The http://cheatsheet.processwire.com/ is always a nice thing to check for options available.

  • Like 2
Link to comment
Share on other sites

prev and next look for a the prev and next pages inside any pageArray, if you use it with the same array that you used to build your posts list, it will respect that order.

  • Like 1
Link to comment
Share on other sites

prev and next look for a the prev and next pages inside any pageArray, if you use it with the same array that you used to build your posts list, it will respect that order.

Yes i noticed that, its all good i want ot use that but only when inside category. On home page i want to be able to click next nad prev and stay within "home page array",

Something like?:

//populate a PageArray

$articleList = $pages->find("template=article, limit=25")

//next

$page->next($articleList)

//prev

$page->prev($articleList)

This assumes your articles have their own template. You can put more options, like sort, in the page selector. The http://cheatsheet.processwire.com/ is always a nice thing to check for options available.

I think thats what i was looking for :) i will test it once im back from work.

Thank alot, as allways i can count on your help here. :) thx very much !!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...