tooth-paste Posted October 24, 2015 Share Posted October 24, 2015 Is it possible to combine these two scripts. One for automatically create rows in foundation in combination with pagination. $columns = $page->children; $colcount = $columns->count(); $i = 1; echo '<div class="row">'; foreach ($columns as $column) { if($i == $colcount){ echo "<div class='medium-4 columns end'> <a href='{$column->url}'><img src='{$column->webshop_child->first()->url}' alt='' /></a>"; } else { echo "<div class='medium-4 columns'> <a href='{$column->url}'><img src='{$column->webshop_child->first()->url}' alt='' /></a>"; }; if($i % 3 == 0) {echo '</div></div><div class="row">';} else {echo '</div>';} $i++; } echo '</div>'; This pagination I found in the docs. $results = $page->children("id>1, limit=5, sort=title"); $pagination = $results->renderPager(); echo "<ul>"; foreach($results as $result) { echo "<li>{$result->title}</li>"; } echo "</ul>"; echo $pagination; Link to comment Share on other sites More sharing options...
Webrocker Posted October 24, 2015 Share Posted October 24, 2015 Hi, I'm not sure what you're trying to achive; but if you want to have your first example in combination with the pagination, you could do it like this: $pageItems = 10; $columns = $page->children('limit='.$pageItems); $colcount = $columns->count(); $pagination = $columns->renderPager(); $i = 1; echo '<div class="row">'; foreach ($columns as $column) { if($i == $colcount){ echo "<div class='medium-4 columns end'> <a href='{$column->url}'><img src='{$column->webshop_child->first()->url}' alt='' /></a>"; } else { echo "<div class='medium-4 columns'> <a href='{$column->url}'><img src='{$column->webshop_child->first()->url}' alt='' /></a>"; }; if($i % 3 == 0) { echo '</div></div><div class="row">'; } else { echo '</div>'; } $i++; } echo '</div>'; // new row with on col span full width for the pager; change according to your layout echo '<div class="row">'; echo '<div class="medium-12 columns">'; echo $pagination; echo '</div></div>'; You could save some lines of code if you catch the class for the last column instead of if/else the nearly identical lines: $pageItems = 10; $columns = $page->children('limit='.$pageItems); $colcount = $columns->count(); $pagination = $columns->renderPager(); $i = 1; echo '<div class="row">'; foreach ($columns as $column) { $colClass = 'medium-4 columns'; if($i == $colcount){ $colClass .= ' end'; } echo "<div class='{$colClass}'> <a href='{$column->url}'><img src='{$column->webshop_child->first()->url}' alt='' /></a>"; if($i % 3 == 0) { echo '</div></div><div class="row">'; } else { echo '</div>'; } $i++; } echo '</div>'; echo '<div class="row">'; echo '<div class="medium-12 columns">'; echo $pagination; echo '</div></div>'; cheers, Tom Link to comment Share on other sites More sharing options...
Martijn Geerts Posted October 24, 2015 Share Posted October 24, 2015 Most popular frameworks have inflexible grids as they are based on floats and need row markup. I would go for a inline-block grid in most / all cases. Inline-block grids don't need rows to function but you can use them when you wish. Full browser support ie8 and up. Here's a grid made by Nicolas Gallagher (Writer of the micro clearfix) http://necolas.github.io/griddle/ 5 Link to comment Share on other sites More sharing options...
tooth-paste Posted October 25, 2015 Author Share Posted October 25, 2015 I'am now building the page in blocks. In total I have 8 children, so it results gets sorted into two pages. However, the link '2' and 'next' don't work. What did I miss. $blocks = $page->children("limit=6"); $pagination = $blocks->renderPager(); echo "<ul class='medium-block-grid-3'>"; foreach ($blocks as $block) { echo "<li><a href='{$block->url}'><img src='{$block->webshop_child->first()->url}' /></a></li>"; } echo "</ul>"; echo $pagination; Link to comment Share on other sites More sharing options...
Webrocker Posted October 26, 2015 Share Posted October 26, 2015 You have to enable the pagination in your backend-template_ "Enabling Pagination Make sure the "Pager" (MarkupPagerNav) module is installed in Admin > Modules. If it's not installed, click the Install link next to it. Determine what template(s) you want to use pagination with. Go to Admin > Setup > Templates > [Your Template] > URLs, and check the box for: Allow Page Numbers. Save. Pagination should now be enabled and ready to use in your templates." (http://processwire.com/api/modules/markup-pager-nav/) cheers,Tom 2 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