MuchDev Posted September 9, 2014 Share Posted September 9, 2014 Hello, I'm back . So I am currently doing some more work on a template that holds virtual exhibitions for my gallery project. The way that the template currently functions like so. An exhibition contains artworks and artwork sections. The artwork can either be a child of the page, a child of a subsection (when this happens there will be a page division and headline text), or it can be specifically chosen via a multipage selector inside of the template. What I would like to do is implement pagination into this. Currently I grab all children items by using a selector , and then combine everything from the pagefield to a variable $items by executing $items->import. Is there a simple way to limit the items displayed once everything has been combined. Something like $items("limit=35")? This is my current logic: if ($page->Artwork_in_Inventory){ $inventoryItems = $page->Artwork_in_Inventory; } $items = $inventoryItems; $items->import($page->children); Link to comment Share on other sites More sharing options...
horst Posted September 9, 2014 Share Posted September 9, 2014 I'm in a hurry: https://www.google.com/search?q=site:processwire.com+pagination https://www.google.com/search?q=site:processwire.com%2Ftalk+pagination https://processwire.com/api/modules/markup-pager-nav/ (limit) ... 1 Link to comment Share on other sites More sharing options...
MuchDev Posted September 9, 2014 Author Share Posted September 9, 2014 Hey thanks I've definitely spent some time googlin but that final link held the answer. I've not seen that part of the cheatsheet, thanks for the link ! K so I am going to use setLimit('x') perfect! So happy. 1 Link to comment Share on other sites More sharing options...
MuchDev Posted September 9, 2014 Author Share Posted September 9, 2014 So this is working pretty much as planned, but what I am wondering now is this. I am currently using logic to separate out the items once they have been fetched. I am grabbing all children of the page but some of the children have their own children that I then loop over. I feel that I should change this to a more simple selector that grabs all items including children before I loop them. Any thoughts? Here is the more final code, I still have to implement pagination better but I have a working test elsewhere. (I've stripped most of the markup out to make the code as readable as I could manage) $inventoryItems = $page->Artwork_in_Inventory; $items = $inventoryItems; $items->import($page->children); $items->setLimit(35); //social dropdown and pagination menu echo '<div class="pageNavTop">'; echo '<div class="socialHolder">'; echo renderSocial(); echo '</div>'; echo $items->renderPager(array( 'listMarkup' => "<ul class='pagination pageNavBtns'>{out}</ul>", 'currentItemClass' => "active")); echo '<div class="hrHolder">'; echo '<hr/>'; echo '</div>'; echo "</div>"; foreach($items as $item){ $generated = false; //Remember to not return any tags in the string if no information has been returned. //option 1 - one is an item and then just print it. if ($item->template->name === 'items'){ $gridSizer = $item->gridSizer; echo generateItem($item,$gridSizer); $generated = true; } //option 2 is a subsection. Print 100%width divider with text areas if ($item->template->name === 'itemsSection'){ echo "<div class='grid-item masonrySection col-xs-12'>"; //echo $item->gridSizer; //echo "<h2>{$item->title}</h2>"; if ($item->subsection_description){ echo "<p>{$item->subsection_description}</p>"; } echo "</div>"; foreach ($item->children() as $subitem){ $gridSizer = 1; if ($subitem->gridSizer){ $gridSizer = $subitem->gridSizer; } echo generateItem($subitem,$gridSizer); } } } 1 Link to comment Share on other sites More sharing options...
MuchDev Posted September 10, 2014 Author Share Posted September 10, 2014 One more while I'm at it. In order to locate this page based on the items that are contained within the pagefield will I need search for the page or can I just search by the included pages ID? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now