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)
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:

Page Index


This is an alphabetical list of pages you can read on this server.
 
All  #  A  #  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 

J
JabberPresence [JabberPresence] . . . . Owner: PivWan
JackOfShadows [JackOfShadows] . . . . Owner: JackOfShadows
jaguar [jaguar] . . . . Owner: RichardSteven
JamesMcl [JamesMcl] . . . . Owner: JamesMcl
JanieJones56 [JanieJones56] . . . . Owner: JanieJones56
JanPiotrowski [JanPiotrowski] . . . . Owner: JanPiotrowski
jasonalvis [jasonalvis] . . . . Owner: jasonalvis
JasonHuebel [JasonHuebel] . . . . Owner: JasonHuebel
JasRandal [JasRandal] . . . . Owner: JasRandal
JavaScript [JavaScript] . . . . Owner: DarTar
JavaWoman [JavaWoman] . . . . Owner: JavaWoman
JeanRoure [JeanRoure] . . . . Owner: JeanRoure
JeffCarter [JeffCarter] . . . . Owner: JeffCarter
JeffWhite [JeffWhite] . . . . Owner: JeffWhite
JeffWhite2 [JeffWhite2] . . . . Owner: JeffWhite
JeJeOfLoVe [JeJeOfLoVe] . . . . Owner: JeJeOfLoVe
JenniferM [JenniferM] . . . . Owner: JenniferM
JenniferSalamon [JenniferSalamon]
JensFischer [JensFischer] . . . . Owner: JensFischer
JensGiesemann [JensGiesemann] . . . . Owner: JensGiesemann
JensPoder [JensPoder] . . . . Owner: JensPoder
JeremyYip [JeremyYip] . . . . Owner: JeremyYip
JeroenAlberts [JeroenAlberts] . . . . Owner: JeroenAlberts
JeroenJansen [JeroenJansen] . . . . Owner: JeroenJansen
JerryC [JerryC] . . . . Owner: JerryC
JeyRey [JeyRey] . . . . Owner: JeyRey
JfDelesse [JfDelesse] . . . . Owner: JfDelesse
JiangHe [JiangHe] . . . . Owner: JiangHe
JimboBrown [JimboBrown] . . . . Owner: JimboBrown
JimJohnson61 [JimJohnson61] . . . . Owner: JimJohnson61
JirongZhou [JirongZhou] . . . . Owner: AdminUser
JockeAndersson [JockeAndersson] . . . . Owner: JockeAndersson
JoeD [JoeD] . . . . Owner: JoeD
JoelCant [JoelCant] . . . . Owner: JoelCant
JoelPenner [JoelPenner] . . . . Owner: JoelPenner
JoeWalker [JoeWalker] . . . . Owner: JoeWalker
JohanF [JohanF] . . . . Owner: JohanF
JohnC [JohnC] . . . . Owner: JohnC
JohnDeBruyn [JohnDeBruyn] . . . . Owner: JohnDeBruyn
JohnFrancisLee [JohnFrancisLee] . . . . Owner: JohnFrancisLee
JohnMcauley [JohnMcauley] . . . . Owner: EoinK
JonathanMitchem [JonathanMitchem] . . . . Owner: JonathanMitchem
JoniX [JoniX] . . . . Owner: JoniX
JonWatson [JonWatson] . . . . Owner: JonWatson
JordaPolo [JordaPolo] . . . . Owner: JordaPolo
JSMathIntegration [JSMathIntegration] . . . . Owner: ImagistTD
JsnX [JsnX] . . . . Owner: JsnX
JuanGonzalez [JuanGonzalez] . . . . Owner: JuanGonzalez
JuHyeon [JuHyeon] . . . . Owner: JuHyeon
JulianElve [JulianElve] . . . . Owner: JulianElve
Julio500 [Julio500] . . . . Owner: Julio500
JumBo09 [JumBo09] . . . . Owner: JumBo09
JwCalendar [JwCalendar] . . . . Owner: JavaWoman
JwCalendarWithPageCreation [JwCalendarWithPageCreation] . . . . Owner: ChristianBarthelemy
JwRssTest [JwRssTest] . . . . Owner: JavaWoman



Code


[26/9/04] actions/pageindex.php file after this mod:

<?php
if ($pages = $this->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 = "<strong><a href='$link'>All </a></strong> \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 .= "<strong><a href='$link$firstChar'>$firstChar</a></strong> \n";
			$current_character = $firstChar;
			$character_changed = true;
		}
		if ($requested_letter == '' || $firstChar == $requested_letter) {
			if ($character_changed) {
				$index_output .= "<br />\n<strong>$firstChar</strong><br />\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 .= "<br />\n";    
		}
	}
	$index_header .= "<br />";
	if ($user_owns_pages) $index_output .= "<br />\n* Indicates a page that you own.<br />\n";    
	print $index_header.$index_output;
} else {
	print("<em>No pages found.</em>");
}
?>
There are 5 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki