====Anchor in a Wiki page==== Make a file named anchor.php to put at ./actions directory. The content is %%(php) Parameters : § name : name of anchor to set § target : name of an anchor to go to § text : Text to be displayed on link to anchor, optional § title : optional, a code {{anchor target="Sometarget"}} without the parameter text will display between tags and the value of parameter title, if set, when defining {{anchor name="Sometarget"}}. (see usage). § h3 : Dispaly a

tag after the anchor newly set, all link to that anchor without the parameter text will have h3 as caption. § special : if this parameter is set, its value should be one of "table_of_contents" or "usage" > parameter name goes with title or h3, should not be used with parameter target. > parameter target goes with text. Special use : . {{anchor special="table_of_contents"}} : Display a list of anchors having the parameter h3 set. . {{anchor special="usage"}} : Show this help. Usage : {{anchor name="top" title="Top of page"}} => {{anchor target="top"}} => Top of page {{anchor target="top" text="Back to top"}} => Back to top {{anchor name="paragraph1" h3="Introduction"}} =>

Introduction

{{anchor target="paragraph1"}} => Introduction **/ $_SESSION['anchor_list']; $name = $vars['name']; $text = $vars['text']; $target = $vars['target']; $special = $vars['special']; if ($special) { if ($special == 'table_of_contents') { echo "<>"; } if ($special == 'usage') { $fp = fopen('actions/anchor.php', 'r'); $data = fread($fp, 1000000); $data = preg_replace("#(^.*/\*\*|\*\*/.*$)#ms", '', $data); echo nl2br(htmlspecialchars($data)); fclose($fp); } } else { if ($name) { echo ""; if ($vars['h3']) { echo "

$h3

"; $this->anchor_list[$name] = $h3; $this->anchor_list['table_of_contents'] .= "Href('', $this->tag) ."#$name\">$h3
\n"; } if ($vars['title']) { $this->anchor_list[$name] = $title; } } if ($target) { if (!$text) { if ($this->anchor_list[$target]) { $text = $this->anchor_list[$target]; } else { $text="<>"; } } echo "Href('', $this->tag)."#$target\">$text"; } } ?> %% ~& I changed the last line in the above code to use ""$this->Href('', $this->tag)"" instead of $this->tag. NickDamoulakis ~& I changed the other line in the above code to use ""$this->Href('', $this->tag)"" instead of $this->tag and also fixed the {} as per comments below. MyTreo Following lines shoud be added at end of ./formatters/wakka.php : %%(php) if (isset($this->anchor_list)) { $text = preg_replace("/<>/e", "\$this->anchor_list['\\1'] ? \$this->anchor_list['\\1'] : '\\1';", $text); } echo ($text); wakka2callback('closetags'); ?>%% ---- Pierre79 -07/3/05 I propose to write ... in the head of header.php v ; in the foot of footer.php.php ^ '; ~&The name attribute for identifying page fragments is deprecated though; better to use id instead (still valid in XHTML 1.0 strict and 1.1, probably also will be in 2.0). See also TableOfContentsAction for related ideas about generating anchors. --JavaWoman ~~&ph Thank you. Do not hesitate to correct my text directly and... to remove this message --Pierre79 ---- In Header.php, add (only!) the lines that begin with ""----->"" %%(php) // Create anchor -----> <?php echo $this->GetWakkaName().": ".$this->PageTitle(); ?> GetMethod() != 'show' || $this->page["latest"] == 'N' || $this->page["tag"] == 'SandBox') echo "\n"; ?> " /> " /> >

config["wakka_name"] ?> : GetPageTag(); ?>

Link($this->config["root_page"]); // Create link to bottom anchor -----> echo " :: Href('', $this->tag)."#bottom\">Go bottom"; ?>%% NickDamoulakis ---- In Footer.php, add (only!) the lines that begin with ""----->"" %%(php) echo $this->FormOpen("", "TextSearch", "get"); // Create anchor -----> echo(''); // Create link to top anchor -----> echo "Href('', $this->tag)."#top\">Go top :: "; echo $this->HasAccess("write") ? "href("edit")."\" title=\"Click to edit this page\">Edit page ::\n" : ""; echo "href("history")."\" title=\"Click to view recent edits to this page\">Page History ::\n"; echo $this->GetPageTime() ? "href("revisions")."\" title=\"Click to view recent revisions list for this page\">".$this->GetPageTime()." href("revisions.xml")."\" title=\"Click to view recent page revisions in XML format.\">\"XML\" ::\n" : ""; // if this page exists %% NickDamoulakis ~& I changed above code to use %%".$this->Href('', $this->tag)."%% instead of %%{$this->Href('', $this->tag)}%% MyTreo ==Category== CategoryUserContributions