We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum
Forum
Alphabetical pagination not working since upgrade
Hi Guys,
Any ideas as to why upgrading from perch 2 -> 3 would cause the following code to break?
<div class="container // margin-top">
<?php
// setup alphabet array for navigation
// make array of letters in <li> tags with class disabled
for ($i = 65; $i <= 90; $i++) {
$nav_arr[chr($i)] = '<li class="disabled">'.chr($i).'</li>';
}
// Go through content, if an item title begins with a letter, make it into a link instead of a span.
// $current_letter = '';
perch_collection('Artists', [
'skip-template' => true,
'raw' => true,
'sort' => 'artist_firstname',
'sort-order' => 'ASC',
'filter' => 'artist_show',
'match' => 'eq',
'value' => 'show',
'each' => function($item) {
$word = strtoupper($item['artist_firstname']);
// if the first letter of the title is different to current_letter, it's new so add it to nav_arr
if (strcmp($word[0], $GLOBALS['current_letter']) !== 0) {
$current_letter = perch_get('page');
$current[$current_letter] = 'class="active"';
$my_letter = $GLOBALS['current_letter'] = $word[0];
$GLOBALS['nav_arr'][$my_letter] = '<li '.$current[strtolower($my_letter)].'><a href="/artists/'.strtolower($my_letter).'/">'.$my_letter.'</a></li>';
}
return $item;
}
]);
?>
<nav id="nav" role="navigation" class="pagination // pagination--left">
<ul class="page-links">
<?php
// Display our alphabet
foreach ($nav_arr as $key => $value) {
echo $value;
}
?>
</ul>
</nav>
</div>
Want to reply to this thread?
Login with Perch
How is it breaking?
All the letters appear as disabled. www.supershoes.org.uk/artists/a
I think you'll just need to step through and debug it. Not sure what help I can offer from here.
Ok I will do Drew. As it broke after upgrading I wondered if I was using something that I should no longer be using.