====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"}} =>
";
$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
-----> GetWakkaName().": ".$this->PageTitle(); ?>
GetMethod() != 'show' || $this->page["latest"] == 'N' || $this->page["tag"] == 'SandBox') echo "\n"; ?>
" />
" />
>