Thread tagged as: Question

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">
        // 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">
                // Display our alphabet
                foreach ($nav_arr as $key => $value) {
                    echo $value;
Terry Upton

Terry Upton 0 points

  • 2 months ago
Drew McLellan

Drew McLellan 2486 points
Perch Support

How is it breaking?

All the letters appear as disabled.

Drew McLellan

Drew McLellan 2486 points
Perch Support

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.