We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16501
    • 28 Posts
    Has anyone got alphabetic pagination working with either separate pages for each letter or a to z anchors?
      • 16501
      • 28 Posts
      Well it’s a bit dodgy grin, but it works (for me!).

      In webloginpe.class.php right after $eachProfile = $listTemplate; on line 1238 I threw in the following code
      $anchor = $theUser[$format[3]];
      $eachProfile = "<a name=\"" . strtoupper($anchor[0]) . "\"></a><p></p>" . $eachProfile;
      


      So what it’s doing is just throwing an anchor tag before each user and grabbing the first letter of the sortBy field.

      And then I modified the A to Z Listing snippet (http://modxcms.com/extras/package/?package=2) to output the A to Z headings.
      <?php
      //-- Alphabet Letters
      $alphabet = array (
      	"A",
      	"B",
      	"C",
      	"D",
      	"E",
      	"F",
      	"G",
      	"H",
      	"I",
      	"J",
      	"K",
      	"L",
      	"M",
      	"N",
      	"O",
      	"P",
      	"Q",
      	"R",
      	"S",
      	"T",
      	"U",
      	"V",
      	"W",
      	"X",
      	"Y",
      	"Z"
      );
      
      $lcount = count($alphabet); // number of letters in the alphabet
      
      //-- placeholder variables
      $atozletters = '';
      
      //-- used for makeURL for current page
      $docid = $modx->documentObject['id'];
      
      //-- Output Alphabet Headings
      for ($i = 0; $i < $lcount; $i++) {
      	if ($i < $lcount -1) {
      		$atozletters .= '<span class="azalpha"><a href="' . $modx->makeURL($docid, '', '#' . $alphabet[$i] . '') . '">' . $alphabet[$i] . '</a></span><span class="azsep"> | </span>';
      	} else {
      		$atozletters .= '<span class="azalpha"><a href="' . $modx->makeURL($docid, '', '#' . $alphabet[$i] . '') . '">' . $alphabet[$i] . '</a></span>';
      	}
      }
      return $atozletters;
      ?>