Re: Collapse navlink config under heading in backend
Posted: Wed May 09, 2012 8:15 pm
I have never used global navigation. If it is not in the template, where is it configured?
User and developer community
https://board.s9y.org/
Code: Select all
$template_global_config = array('navigation' => true);
$template_loaded_config = serendipity_loadThemeOptions($template_config, $serendipity['smarty_vars']['template_option'], true);
serendipity_loadGlobalThemeOptions($template_config, $template_loaded_config, $template_global_config);
Code: Select all
/* Collapsable navigation and config groups i.e. Sliver template */
$template_global_config = array('navigation' => true);
$template_loaded_config = serendipity_loadThemeOptions($template_config, $serendipity['smarty_vars']['template_option'], true);
serendipity_loadGlobalThemeOptions($template_config, $template_loaded_config, $template_global_config);
foreach($template_loaded_config as $key=>$value) {
if (preg_match('#^(amount)#', $key, $matches)===1 || preg_match('#^(navlink+)#', $key, $matches)===1) {
$navonly[] = $key; // todo: if key has sublink follow until end, then proceed
}
}
// sort by amount and navlink[digit]
asort($navonly);
// asorted Elements will be arranged from lowest to highest with new keys
sort($navonly);
$template_config_groups = array(
THEME_WELCOME => array('about'),
THEME_LAYOUT => array('sidebars', 'webfonts', 'userstylesheet', 'use_slivers_JQueryMin', 'use_google_analytics', 'google_id', 'layouttype', 'firbtitle', 'firbdescr'),
THEME_ENTRIES => array('date_format', 'entryfooterpos', 'footerauthor', 'send2printer', 'footercategories', 'footertimestamp', 'footercomments', 'footertrackbacks', 'altcommtrack', 'show_sticky_entry_footer', 'show_sticky_entry_heading', 'prev_next_style', 'show_pagination'),
THEME_SIDENAV => array('sitenavpos', 'sitenavstyle', 'sitenav_footer', 'sitenav_quicksearch', 'sitenav_sidebar_title'),
THEME_NAV => $navonly
);
No. The global navigation is a "straight-ahead, easy" solution. Anything more specific should be solved in the individual template's config.inc file, no need to blow up the code in the core... $0.02Don Chambers wrote:Does it support more than one navbar? Does it support subnavigation?
Agreed.garvinhicking wrote:... no need to blow up the code in the core... $0.02
Code: Select all
// sort algorithm that orders alphanumeric strings in the way a human being would
natsort($nav2onlydon);
// returns all the values from the input array and indexes numerically the array.
$nav2onlydon = array_values($nav2onlydon);
Code: Select all
sort($nav2onlydon);
Code: Select all
Array
(
[0] => nav2link0sitenav2_amount
[1] => nav2link0target
[2] => nav2link0text
[3] => nav2link0url
[4] => nav2link0zsublink0target
[5] => nav2link0zsublink0text
[6] => nav2link0zsublink0url
[7] => nav2link0zsublink1target
[8] => nav2link0zsublink1text
[9] => nav2link0zsublink1url
[10] => nav2link0zsublink2target
[11] => nav2link0zsublink2text
[12] => nav2link0zsublink2url
[13] => nav2link0zsublink3target
[14] => nav2link0zsublink3text
[15] => nav2link0zsublink3url
[16] => nav2link1sitenav2_amount
[17] => nav2link1target
[18] => nav2link1text
[19] => nav2link1url
[20] => nav2link2sitenav2_amount
[21] => nav2link2target
[22] => nav2link2text
[23] => nav2link2url
[24] => nav2link3sitenav2_amount
[25] => nav2link3target
[26] => nav2link3text
[27] => nav2link3url
[28] => nav2link4sitenav2_amount
[29] => nav2link4target
[30] => nav2link4text
[31] => nav2link4url
[32] => sitenav2_amount
)
Code: Select all
Array ( [0] => sitenav2_amount [1] => navlink20text [2] => navlink20target [3] => navlink20sitenav2_amount [4] => navlink21text [5] => navlink21target [6] => navlink21sitenav2_amount [7] => navlink22target [8] => navlink22sitenav2_amount [9] => navlink23text [10] => navlink23url [11] => navlink23target [12] => navlink23sitenav2_amount [13] => navlink24text [14] => navlink24url [15] => navlink24target [16] => navlink24sitenav2_amount [17] => navlink20url [18] => navlink21url [19] => navlink22text [20] => navlink22url [21] => navlink20sublink3url [22] => navlink20sublink3target [23] => navlink20sublink2target [24] => navlink20sublink3text [25] => navlink20sublink2text [26] => navlink20sublink2url [27] => navlink20sublink1url [28] => navlink20sublink1target [29] => navlink20sublink0target [30] => navlink20sublink1text [31] => navlink20sublink0text [32] => navlink20sublink0url )
In fact, using your method to collapse the navlinks has revealed a problem for me... the order these items are listed in is the order they were saved in the options table.... they not are not necessarily being displayed alphabetically/numerically. When first created, I had "parent" links, each with text, url, etc. Some time later I added "child" sublinks.
This is very important, especially for a collapsed section of multiple items. It is much cleaner to have a heading for each repetitive group, ie:Timbalu wrote:This now very well works for the sort and the collapsing header config group, but does not solve the 'type' => 'content' parts, which still appear outside the collapsing scope.
I assume that would mean to clone the function doing the $template_config_groups magic, to also support 'content' values. But this is an other story...!
I appreciate your help - I really do! What I meant is that prior to collapsing these items, they were printed in the order listed in the template config, inclusive of sublinks, regardless of what order they were saved in the database, and regardless of any alphabetic issues. They printed correctly because they were being emitted by loops:Timbalu wrote:What do you mean by "former method" does not work as expected?
Code: Select all
Array
(
......
[navlink4url] => #
[navlink4text] => Link #5
[navlink3url] => #
[navlink3text] => Link #4
[navlink2url] => #
[navlink2text] => Link #3
[navlink1url] => #
[navlink1text] => Link #2
[navlink0url] => #
[navlink0text] => Link #1
[amount] => 8
[navlink5text] => I am 6
[navlink5url] => #
[navlink6text] => Link #7
[navlink6url] => #
[navlink7text] => I am 8
[navlink7url] => #
.......
}