Wiki source for OnegWRSubPages


Show raw source

===== Sub-Pages Action =====
>>==See Also==
~- [[OnegWRTree | Tree]] - Also show some hierarchical structure.
>>//NOT Included in any Wikka version yet//{{lastedit}}
==What==
~- Create a menu with links to sub-pages.
~- A page is considered a sub-page if the first x chars are the same as the current page.
~- Optional you can define an other page than the current by using the "page" parameter.

==Use==
~- Include on the page where you would like to include this menu this string:
~~""{{subpages}}"" or
~~""{{subpages page="HomePage"}}""

==Features==
~- If there are no subpages found, nothing will be included.
~- The "page" parameter needs to be a existing page, otherwise the current page will be used.
~- The first x chars that are identical to the parent-page are removed. If you like to see the full name, uncomment the right code in the foreach-loop.
~- Layout (hor, vert, colors,...) can be done by giving the right option to the "ul.subpage" class in CSS.

==Parameters==
~""<table cellspacing="0" cellpadding="2" border="1">
<thead>
<tr><th scope="col">name</th><th scope="col">type</th><th scope="col">required?</th><th scope="col">default</th><th scope="col">description</th></tr>
</thead>
<tbody>
<tr><td>page</td><td>string</td><td>optional</td><td>current page</td><td>The page that will be used to show the subpages from.</td></tr>
</tbody>
</table>""

==Installation==
~- Save the code below as ##actions/subpages/subpages.php##
~- Give it the same file permissions as the php files in the actions directory.
~- Note: function ""ExistsPage"" is included in 1.1.6.0

==Code==
%%(php)
<?php
// Shows pagenames that have the current pagename as start.
// by OnegWR, may 2005, license GPL
// modified by NickAldwin, April 2010

if( is_array($vars) AND isset($vars['page']) AND $this->ExistsPage($vars['page']) ){
$sp_tag = $vars['page'];
}else{
$sp_tag = $this->GetPageTag();
}
$sp_len = strlen($sp_tag);
$sp_links = array();
$sp_str = "SELECT `tag` FROM `".$this->config["table_prefix"]."pages` ".
"WHERE `tag` LIKE '".$sp_tag."%' ".
"AND `latest` = 'Y' ORDER BY `tag` ASC";

if ($sp_pages = $this->LoadAll( $sp_str )){
foreach($sp_pages as $sp_page){
if ($sp_tag == $sp_page['tag']) continue;
//$sp_links[]=$this->Link($sp_page['tag']); // Show full name
$sp_links[]=$this->Link($sp_page['tag'],'',substr($sp_page['tag'],$sp_len));
}
if( count( $sp_links ) > 0 ){
print "\t\t<ul class=\"subpages\">\n\t<li>";
print implode("</li>\n\t<li>", $sp_links);
print "</li>\n</ul>\n\n";
}
}
?>
%%
==History==
~- Published on main site (2005-05-09) - OnegWR
~- Fixed counting bug & instructions (2011-04-11) - NickAldwin


----
CategoryUserContributions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki