to use this MarkUp including
at least one wiki-page address, the second is used in case the
first wiki-page doesn't exist.
* Example CODE:
*****************************************************************/
function parseMenu($args){
global $SiteGroup ;
$fluff = true ;
## Example Navigation page entry:
// * [[$SiteGroup/NavBar?GroupNav={$Group}/GroupNav | Nav Menu ]]
#- The Asterix flags it as a visible menu item w/ level one
#- Normal pmwiki markup makes it a link named "Nav Menu".
#- the link passes the $_GET var "GroupNav" with a second
#- page address to be appended to the first when building
#- this menu. Here the "{$Group}" Markup-Variable looks for
#- the "GroupNav" page in whatever Group you are currently in.
#- If we can't find that, we use /$SiteGroup/GroupNav instead.
// $uri = explode("/",$_SERVER['REQUEST_URI']) ;
// $Group = $uri[1] ;
// $pagename=$GLOBALS['MarkupToHTML']['pagename'];
// $group = PageVar($pagename, '$Group');
## Split the provided args so we can extract each/any
$ArgsArr = explode(" ", $args[1]) ;
## Sanitize:
$WikiPage = strtok($ArgsArr[0], "?") ;
if(!PageExists($WikiPage)){ //look for Group Page
$WikiPage = strtok($ArgsArr[1], "?") ; // Sanitize
}
$arrayPage = ReadPage($WikiPage) ;
## Allow bypass of Menu Builder using Markup -- (:Splash ... :)
## to display an image instead of a menu
$Splash = substr(trim($arrayPage['text']), 0,8) ;
if( $Splash === '(:Splash' || $Splash === '(:splash'){
$trimString = substr(trim($arrayPage['text']), 9) ;
return rtrim( $trimString, ":)") ;
}else{
## Otherwise we break down the page line by line and look for menu items.
## Split the line into an array using New-Line as the delimiter
$pullText = str_replace("\r", "", $arrayPage['text']) ;//drop Chr(13)
$LineItems = explode("\n", $pullText) ;
## Mark the end position with a dummy marker:
array_push($LineItems,"@ EOA");
## Start Building our Menu structure:
$FullBar = "" ; }
$FullBar .= $urTag . "" ;
}elseif( $liCT == $urCT ){
$FullBar .= $urTag . "" ;
}elseif( $liCT > $urCT ){
$FullBar .= $urTag . "- " ;
$DropLI++ ;
}elseif( $liCT < $urCT ){
$FullBar .= $urTag . "
" ;
while($DropLI > 0){ $FullBar .= "" ; }
$FullBar .= "" ;
}
}
## Roll current item into the "Previous" position
$urTag = $liTag ;
## Roll current drop-level to the "Previous" level
$prevLevel = $liLevel ;
}
} // for each
return $FullBar;
}
} // MakeFlatMenu()
## the Markup itself:
Markup( 'parseMenu',
'inline',
'/\\(:parseMenu(?s).(.*?):\\)/',
"parseMenu"
);
## This hides the "Splash" markup which bypasses the Parse function.
## For example to insert a picture instead of a Menu for certain groups:
## the wiki page would use the Splash markup to bypass the Menu builder.
/* (:Splash https://www.mydomain.org/pmwiki/media/welcome_image.png :) */
Markup( 'SplashMenu',
'inline',
'/\\(:Splash (.*?):\\)/',
"$1"
);
## Menu Horizontal-Rule Markup:
Markup( 'menuHR',
'inline',
'/\*(.*?)\\(:hr:\\)/',
"
"
);
## Menu Empty-line or "Spacer" Markup:
Markup( 'menuSpacer',
'inline',
'/\*(.*?)\\(:spacer:\\)/',
""
);
## By Using MenuStart and MenuEnd Markup
## We can have decorated pages which include the actual menu as well
Markup( 'menuStart',
'style',
'/\\(:Menu:\\)/',
""
);
## The SpliceNav Markup allows the Splicing of Menu Pages so
## you can have a Site Navigation Menu page and also have
## {Group} Navigation Pages, which can be combined.
## Using the (:SpliceNav:) Markup you can add/splice the
## {Group} Navigation page to the bottom of the
## Site Navigation page ( for Responsive Themes)
## NB!: This requires passing the spliced page link as part of the URL
## using a $_GET var
## e.g.: ?GroupNav=Group/Page with the link address.
## For example I have a {Group}/MiniNav page with one Link - /*
// * [[Site/NavBar?GroupNav={$Group}/GroupNav | Nav Menu ]]
## This splices the current {Group}/GroupNav page onto Site/NavBar page
function SpliceNav(){
if(isset($_GET['GroupNav'])){
if(PageExists($_GET['GroupNav'])){
return "(:include ".$_GET['GroupNav']." :)" ;
}else{
$outLink = str_replace($Group, "Site", $_GET['GroupNav']) ;
if(PageExists($outLink)){ return "(:include $outLink:)" ; }
}
}
}
Markup( 'SpliceNav',
'fulltext',
'/\\(:SpliceNav:\\)/',
"SpliceNav"
);
## And finally menu-page markup to insert a menu horizontal rule:
## (applied late to only change list items)
Markup('lihrrule','style','/----/','
');
/* CSS
Added to your skin, or to your pub/css/local.css
.hrli, .lihr {
margin-left: 0px ;
width: 80% ;
max-width: 180px ;
border: 0 ;
height: 0 ;
border-bottom: 1px solid ;
}
.hrli {
margin-left: 40px ;}
/*