Jump to content

How to not show "Previous" link on first page in array


webweaver
 Share

Recommended Posts

Quick intro: I'm coming to ProcessWire from ModX with no experience in PHP

I've setup a portfolio on my testing site. The listing page has pagination with 6 pages per web page. When you click to go to a detail page, I have "Previous" and "Next" button links to traverse the detail pages in the portfolio. You can see an example detail page here http://websiteprofessionalstest.com/our-work/villagio-student-housing/ .

The page in the example above is the first page in the array, so I do not want the "Previous Project" button to show. I also do not want the "Next Project" button to show on the last project page.

Here is the code I have tried to not show the "Previous Button" on the first page:

<?php 
			if ($page->prev->url != $page->url): ?>
            <div><a class="project" href="<?php echo $page->prev->url; ?>">« Previous Project</a></div>
            <?php endif; ?>

My thinking here is that on the first page the $page->prev->url and the $page->url are the same, so the if statement shouldn't execute. But it doesn't work. My guess is I'm going about this in a completely wrong way. I tried some other things with PageArray, but I guess I don't understand yet how to work with PageArray and WireArray.

Any help would be a appreciated.

David F

Link to comment
Share on other sites

Thank you for the quick response kongondo, exactly what I was needing - works great..

Btw, kongondo, you were the one who initially got me excited about ModX after I got a handle on Wayfinder using your tutorial. The fact that you're here now is a confirmation that PW is the new game in town :)

  • Like 4
Link to comment
Share on other sites

Small world :D. Nice to know that the book was helpful, thanks. Well, I think I can say with utmost confidence that I'll never get you excited about another CMS :D. It's hard to imagine anything better than PW; I haven't found it and am not looking either ;).

David, welcome to awesomeness! aka PW :).

  • Like 4
Link to comment
Share on other sites

It's hard to imagine anything better than PW; I haven't found it and am not looking either ;).

For four years I said the exact same thing about ModX.. Then I stumbled upon an article from someone explaining why they switched to PW.. I reluctantly checked out PW, because I had already fully committed myself to ModX. Like you, I'm very glad to find PW. And also to find such good community support!

  • Like 1
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...