Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > d8544620e4ac7bee48ddb48c85d55709 > files > 584

ikiwiki-3.20190228-1.mga7.noarch.rpm

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>parentlinks style</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link rel="stylesheet" href="../style.css" type="text/css" />

<link rel="stylesheet" href="../local.css" type="text/css" />










</head>
<body>

<div class="page">

<div class="pageheader">
<div class="header">
<span>
<span class="parentlinks">

<a href="../index.html">ikiwiki</a>/ 

<a href="../tips.html">tips</a>/ 

</span>
<span class="title">
parentlinks style

</span>
</span>



</div>









</div>





<div id="pagebody">

<div id="content" role="main">
<p>Here are some tips for ways to style the links
provided by the <a href="../plugins/parentlinks.html">parentlinks</a> plugin.</p>

<p>This plugin offers a <code>HTML::Template</code> loop that iterates over all or
a subset of a page's parents. It also provides a few bonus
possibilities, such as styling the parent links depending on their
place in the path.</p>

<div class="toc">
<ol>
	<li class="L1"><a href="#index1h1">Content</a>
	</li>
	<li class="L1"><a href="#index2h1">Usage</a>
	<ol>
		<li class="L2"><a href="#index1h2">Basic usage</a>
		</li>
		<li class="L2"><a href="#index2h2">Styling parents depending on their depth</a>
		</li>
		<li class="L2"><a href="#index3h2">Skip some parents, style the others depending on their distance to the current page</a>
		</li>
		<li class="L2"><a href="#index4h2">Avoid showing title of toplevel index page</a>
		</li>
		<li class="L2"><a href="#index5h2">Full-blown example</a>
		</li>
	</ol>
	</li>
</ol>
</div>

<h1><a name="index1h1"></a>Content</h1>

<p>The plugin provides one template loop, called <code>PARENTLINKS</code>, that
returns the list of parent pages for the current page. Every returned
path element has the following variables set:</p>

<ul>
<li><code>URL</code> (string): url to the current path element</li>
<li><code>PAGE</code> (string): title of the current path element</li>
<li><code>DEPTH</code> (positive integer): depth of the path leading to the
current path element, counting from the wiki's root, which has
<code>DEPTH=0</code></li>
<li><code>HEIGHT</code> (positive integer): distance, expressed in path elements,
from the current page to the current path element; e.g. this is
1 for the current page's mother, 2 for its grand-mother, etc.</li>
<li><code>DEPTH_n</code> (boolean): true if, and only if, <code>DEPTH==n</code></li>
<li><code>HEIGHT_n</code> (boolean): true if, and only if, <code>HEIGHT==n</code></li>
</ul>

<h1><a name="index2h1"></a>Usage</h1>

<p>The <code>DEPTH_n</code> and <code>HEIGHT_n</code> variables allow the template writer to
skip arbitrary elements in the parents list: they are arbitrary
page-range selectors.</p>

<p>The <code>DEPTH</code> and <code>HEIGHT</code> variables allow the template writer to apply
general treatment, depending on one of these variables, to <em>every</em>
parent: they are counters.</p>

<h2><a name="index1h2"></a>Basic usage</h2>

<p>As in the default <code>page.tmpl</code>, one can simply display the list of
parent pages:</p>

<pre><code>&lt;TMPL_LOOP NAME="PARENTLINKS"&gt;
&lt;a href="&lt;TMPL_VAR NAME=URL&gt;"&gt;&lt;TMPL_VAR NAME=PAGE&gt;&lt;/a&gt;/ 
&lt;/TMPL_LOOP&gt;
&lt;TMPL_VAR TITLE&gt;
</code></pre>

<h2><a name="index2h2"></a>Styling parents depending on their depth</h2>

<p>Say you want the parent links to be styled depending on their depth in
the path going from the wiki root to the current page; just add the
following lines in <code>page.tmpl</code>:</p>

<pre><code>&lt;TMPL_LOOP NAME="PARENTLINKS"&gt;
&lt;a href="&lt;TMPL_VAR NAME="URL"&gt;" class="depth&lt;TMPL_VAR NAME="DEPTH"&gt;"&gt;
  &lt;TMPL_VAR NAME="PAGE"&gt;
&lt;/a&gt; / 
&lt;/TMPL_LOOP&gt;
</code></pre>

<p>Then write the appropriate CSS bits for <code>a.depth1</code>, etc.</p>

<h2><a name="index3h2"></a>Skip some parents, style the others depending on their distance to the current page</h2>

<p>Say you want to display all the parents links but the wiki homepage,
styled depending on their distance to the current page; just add the
following lines in <code>page.tmpl</code>:</p>

<pre><code>&lt;TMPL_LOOP NAME="PARENTLINKS"&gt;
&lt;TMPL_IF NAME="DEPTH_0"&gt;
&lt;TMPL_ELSE&gt;
&lt;a href="&lt;TMPL_VAR NAME="URL"&gt;" class="height&lt;TMPL_VAR NAME="HEIGHT"&gt;"&gt;
  &lt;TMPL_VAR NAME="PAGE"&gt;
&lt;/a&gt; / 
&lt;/TMPL_IF&gt;
&lt;/TMPL_LOOP&gt;
</code></pre>

<p>Then write the appropriate CSS bits for <code>a.height1</code>, etc.</p>

<h2><a name="index4h2"></a>Avoid showing title of toplevel index page</h2>

<p>If you don't like having "index" appear on the top page of the wiki,
but you do want to see the name of the page otherwise, you can use a
special <code>HAS_PARENTLINKS</code> template variable that the plugin provides.
It is true for every page <em>except</em> the toplevel index.</p>

<p>Here is an example of using it to hide the title of the toplevel index
page:</p>

<pre><code>&lt;TMPL_LOOP NAME="PARENTLINKS"&gt;
&lt;a href="&lt;TMPL_VAR NAME=URL&gt;"&gt;&lt;TMPL_VAR NAME=PAGE&gt;&lt;/a&gt;/ 
&lt;/TMPL_LOOP&gt;
&lt;TMPL_IF HAS_PARENTLINKS&gt;
&lt;TMPL_VAR TITLE&gt;
&lt;/TMPL_IF&gt;
</code></pre>

<h2><a name="index5h2"></a>Full-blown example</h2>

<p>Let's have a look at a more complicated example; combining the boolean
loop variables provided by the plugin (<code>IS_ROOT</code> and friends) and
<code>HTML::Template</code> flow control structures, you can have custom HTML
and/or CSS generated for some special path components; e.g.:</p>

<pre><code>&lt;!-- all parents, skipping mother and grand'ma, inside a common div+ul --&gt;
&lt;div id="oldestparents"&gt;
&lt;ul&gt;
&lt;TMPL_LOOP NAME="PARENTLINKS"&gt;
  &lt;TMPL_IF NAME="HEIGHT_2"&gt;
  &lt;TMPL_ELSE&gt;
    &lt;TMPL_IF NAME="HEIGHT_1"&gt;
    &lt;TMPL_ELSE&gt;
      &lt;li&gt;&lt;a href="&lt;TMPL_VAR NAME="URL"&gt;"&gt;&lt;TMPL_VAR NAME="PAGE"&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;/TMPL_IF&gt;
  &lt;/TMPL_IF&gt;
&lt;/TMPL_LOOP&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;!-- dedicated div's for mother and grand'ma --&gt;
&lt;TMPL_LOOP NAME="PARENTLINKS"&gt;
  &lt;TMPL_IF NAME="HEIGHT_2"&gt;
    &lt;div id="grandma"&gt;
      &lt;a href="&lt;TMPL_VAR NAME="URL"&gt;"&gt;&lt;TMPL_VAR NAME="PAGE"&gt;&lt;/a&gt;
    &lt;/div&gt;
  &lt;TMPL_ELSE&gt;
    &lt;TMPL_IF NAME="HEIGHT_1"&gt;
      &lt;div id="mother"&gt;
    &lt;a href="&lt;TMPL_VAR NAME="URL"&gt;"&gt;&lt;TMPL_VAR NAME="PAGE"&gt;&lt;/a&gt;
      &lt;/div&gt;
    &lt;/TMPL_IF&gt;
  &lt;/TMPL_IF&gt;
&lt;/TMPL_LOOP&gt;

&lt;!-- eventually, the current page title --&gt;
&lt;TMPL_VAR NAME="TITLE"&gt;
&lt;/div&gt;
</code></pre>

</div>







</div>

<div id="footer" class="pagefooter" role="contentinfo">

<div id="pageinfo">











<div class="pagedate">
Last edited <span class="date">Tue Feb 26 23:01:54 2019</span>
<!-- Created <span class="date">Wed Jul 16 21:43:57 2008</span> -->
</div>

</div>


<!-- from ikiwiki -->
</div>

</div>

</body>
</html>