Jump to content

Combining pages from multiple page select and children (limit=xx)


MuchDev
 Share

Recommended Posts

Hello, I'm back :D

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

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);
			}
		}
	}
  • 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

×
×
  • Create New...