Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SOLVED Navigateable Pages Manu
#1
Problem: With alot of pages one can lose track.
Solution: Only show one level of pages and add the possibillity to navigate throug the levels.

in /admin/teplate_functions.php add:
PHP Code:
/**
 * Recursive list of pages
 *
 * Returns only one level of menu, adds option to expand it. 
 *
 * @author Lukas Prömer
 *
 *
 * @param string $parent
 * 
 * @returns string
 */
function get_pages_menu2($parent) {
 global 
$pagesSorted;
 
 
$items=array();

 foreach (
$pagesSorted as $page) {
 if (
$page['parent']==$parent){
 
$items[(string)$page['url']]=$page;
 
$items[(string)$page['url']]['expandable'] = 0;
 foreach (
$pagesSorted as $page2){
 if(
$page2['parent'] == $page['url']){
 
$items[(string)$page['url']]['expandable'] = 1;
 break;
 }
 }
 } 
 }
 if (
count($items)>0){
 foreach (
$items as $page) {
 
  $dash=$cdash="";
 
  if ($page['parent'] != '') {
 
  $page['parent'] = $page['parent']."/";
 
  }
 
 if (
$page['expandable']){
 
  $dash '<span>&nbsp;&nbsp;⋮&nbsp;&nbsp;&nbsp;</span><a href="?p='$page['url'] .'" >';
 
$cdash '</a>';
 } else {
 
$dash '<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
 }
 
 
$menu .= '<tr id="tr-'.$page['url'] .'" >';
 if (
$page['title'] == '' ) { $page['title'] = '[No Title] &nbsp;&raquo;&nbsp; <em>'$page['url'] .'</em>'; }
 if (
$page['menuStatus'] != '' ) { $page['menuStatus'] = ' <sup>['.i18n_r('MENUITEM_SUBTITLE').']</sup>'; } else { $page['menuStatus'] = ''; }
 if (
$page['private'] != '' ) { $page['private'] = ' <sup>['.i18n_r('PRIVATE_SUBTITLE').']</sup>'; } else { $page['private'] = ''; }
 if (
$page['url'] == 'index' ) { $homepage ' <sup>['.i18n_r('HOMEPAGE_SUBTITLE').']</sup>'; } else { $homepage ''; }
 
$menu .= '<td class="pagetitle">'$dash cl($page['title']) .$cdash.'<span class="showstatus toggle" >'$homepage $page['menuStatus'] . $page['private'] .'</span></td>';
 
$menu .= '<td style="width:80px;text-align:right;" ><span>'shtDate($page['pubDate']) .'</span></td>';
 
$menu .= '<td class="secondarylink" >';
 
$menu .= '<a title="'.i18n_r('VIEWPAGE_TITLE').': 'var_out($page['title']) .'" target="_blank" href="'find_url($page['url'],$page['parent']) .'">#</a>';
 
$menu .= '</td>';
 
$menu .= '<td class="secondarylink" ><a title="'.i18n_r('EDITPAGE_TITLE').': 'var_out($page['title']) .'" href="edit.php?id='$page['url'] .'" > ✎</a></td>';
 if (
$page['url'] != 'index' ) {
 
$menu .= '<td class="delete" ><a class="delconfirm" href="deletefile.php?id='$page['url'] .'&amp;nonce='.get_nonce("delete""deletefile.php").'" title="'.i18n_r('DELETEPAGE_TITLE').': 'var_out($page['title']) .'" >&times;</a></td>';
 } else {
 
$menu .= '<td class="delete" ></td>';
 }
 
$menu .= '</tr>'
 }
 }
 return 
$menu;
}
/**
 * Recursive list of pages
 *
 * Returns Breadcrumps for Pages-Menu
 *
 * @author Lukas Prömer
 *
 *
 * @param string $parent
 * 
 * @returns string
 */
 
function get_pages_breadcrumps($parent) {
 global 
$pagesSorted;
 if(
$parent=="") return '<a href="?p">root</a>';
 
 foreach (
$pagesSorted as $page) {
 if ((string)
$page['url']==$parent){
 
$apage $page;
 break;
 }
 }
 
 
$crumps ' >> <a href="?p='.$apage['url'].'">'.var_out($apage['title']).'</a>';
 return 
get_pages_breadcrumps($apage['parent']) . $crumps;
 

 } 

in pages.php replace:
On line 86:
PHP Code:
$table get_pages_menu($_GET['p']); 
with
PHP Code:
$tableCrumps get_pages_breadcrumps($_GET['p']);
$table get_pages_menu2($_GET['p']); 


And before line 108 (before the <table />) add:
PHP Code:
<?php echo $tableCrumps?>
Reply


Messages In This Thread
Navigateable Pages Manu - by Eleftherios - 2016-04-19, 07:48:45
RE: Navigateable Pages Manu - by datiswous - 2016-04-19, 08:00:01
RE: Navigateable Pages Manu - by lokothodida - 2016-04-19, 16:36:00



Users browsing this thread: 1 Guest(s)