==== Wikka Mod 041 ==== Type: Feature Addition ---- ===Credit=== **Mark Kasper** and **GmBowen** **(main credit for the idea and initial code)** **AHerdOfTurtles** (for helping me see that this is a cool idea) **[[JsnX | Jason Tourtelotte]]** (major refinement to the code -- almost a complete rewrite) ---- === Description === This modification adds the ability to show an index listing of pages that start with a certain letter. There is also an alphabetical heading at the top of each listing. Just click a letter to see pages that start with that letter. For example: Usage: %% {{pageindex letter="d"}} %% Outcome: {{pageindex letter="d"}} ---- === Code === [26/9/04] actions/pageindex.php file after this mod: %% LoadAllPages()) { if (isset($_REQUEST["letter"])) $requested_letter = $_REQUEST["letter"]; else $requested_letter = ''; if (!$requested_letter && isset($letter)) $requested_letter = strtoupper($letter); $cached_username = $this->GetUserName(); $user_owns_pages = false; $link = $this->href("", "", "letter="); $index_header = "All \n"; $index_output = ""; $current_character = ""; $character_changed = false; foreach ($pages as $page) { $page_owner = $page["owner"]; // $this->CachePage($page); $firstChar = strtoupper($page["tag"][0]); if (!preg_match("/[A-Za-z]/", $firstChar)) $firstChar = "#"; if ($firstChar != $current_character) { $index_header .= "$firstChar \n"; $current_character = $firstChar; $character_changed = true; } if ($requested_letter == '' || $firstChar == $requested_letter) { if ($character_changed) { $index_output .= "
\n$firstChar
\n"; $character_changed = false; } $index_output .= $this->Link($page["tag"]); if ($cached_username == $page_owner) { $index_output .= "*"; $user_owns_pages = true; } elseif ($page_owner != '(Public)' && $page_owner != '') { $index_output .= " . . . . Owner: ".$page_owner; } $index_output .= "
\n"; } } $index_header .= "
"; if ($user_owns_pages) $index_output .= "
\n* Indicates a page that you own.
\n"; print $index_header.$index_output; } else { print("No pages found."); } ?> %%