Collapse navlink config under heading in backend

Skinning and designing Serendipity (CSS, HTML, Smarty)
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Collapse navlink config under heading in backend

Post by Don Chambers »

I have never used global navigation. If it is not in the template, where is it configured?
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Collapse navlink config under heading in backend

Post by Timbalu »

In core ... functions_config.inc.
But in your templates config you only need these three lines

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);
to let the magic happen in your templates config via functions_config.inc and the options table. :)
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Collapse navlink config under heading in backend

Post by Don Chambers »

Does it support more than one navbar? Does it support subnavigation?
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Collapse navlink config under heading in backend

Post by Timbalu »

indeed ... that is the remaining question.... see my last note to Garvin.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Collapse navlink config under heading in backend

Post by Don Chambers »

In my template, I probably have to stay with navigation as a template option. I have 3 navbars, and the navlist items have an additional parameter (link text, link url, and a boolean value). 2 of the three also have sublink capability.

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. When displayed the old way, they would appear as follows:

Link 0
Link 0 sublink 0
Link 0 sublink 1
Link 0 sublink 2
Link 1
Link 2
Link 3

Displaying them now using your method looks like this:
Link 0
Link 1
Link 2
Link 3
Link 0 sublink 0
Link 0 sublink 1
Link 0 sublink 2
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Collapse navlink config under heading in backend

Post by Timbalu »

To really see what is needed I need to see your whole config file, I assume. If that is OK send it by PM.

The sort was easy at the end....

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
);
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Collapse navlink config under heading in backend

Post by garvinhicking »

Don Chambers wrote:Does it support more than one navbar? Does it support subnavigation?
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.02 :)
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Collapse navlink config under heading in backend

Post by Don Chambers »

garvinhicking wrote:... no need to blow up the code in the core... $0.02 :)
Agreed.
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Collapse navlink config under heading in backend

Post by Timbalu »

[handed over some small code parts via PM]

As I already showed before, the sorting algorithms do their work very well for the global navigation array.

In your special case, ...well..., we have to outsmart the sorting algorithm, as it uses an ascending alphabet. Your array delivers deep strings, which the sort has to bring up right like humans would do.

Notice, I also changed your navlinkNUM to navNUMlink, to seperate naming from iterating numbers.

So you have nav2link0target, nav2link0text, nav2link0url for example and you want to append nav2link0sublink0... in your sort order.

But natural sort order will append [s] before [t], this is why you will have the sublinks in the upper array part.
Now we change the delivery name string using nav2link0zsublink (a.s.o.) and have a fine result. The order Addition [z] as something which can't get overruled. Later on you'll better use 'zlink' there.

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);
which is the same as short:

Code: Select all

sort($nav2onlydon);
Result:

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
)
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...! :wink:
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Collapse navlink config under heading in backend

Post by Don Chambers »

I was hoping not to have to resort to out smarting the available alphabetizing methods... I would still like to know WHY the former method does not work as expected... if they are being printed via a loop, why are they no longer emitted in the original order?
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Collapse navlink config under heading in backend

Post by Timbalu »

What do you mean by "former method" does not work as expected?

I can't really tell you, as the only array to play with - I did not want to spoil my options table submitting - was the one you send to me...

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 )
which was a collect from $template_loaded_config, I assumed, as you wrote:
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.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Collapse navlink config under heading in backend

Post by Don Chambers »

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...! :wink:
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:

My heading for navlink # 1
Navlink text:
Navlink url:
Navlink title:


My heading for navlink #2
Navlink text:
Navlink url:
Navlink title:

Without those headings, it would look more like this:
Navlink#1 text:
Navlink#1 url:
Navlink#1 title:
Navlink#2 text:
Navlink#2 url:
Navlink#2 title:

This second method gets really annoying especially when the labels are rather long, ie, instead of "navlink #1 text", the label is "Enter html code in this box to be displayed below each entry #1'
=Don=
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Collapse navlink config under heading in backend

Post by Don Chambers »

Timbalu wrote:What do you mean by "former method" does not work as expected?
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:

$navlinks2 = array();
for ($i = 0; $i < $template_loaded_config['sitenav2_amount']; $i++) {
......
$sublinks = array();
for ($s = 0; $s < $template_loaded_config['navlink2' . $i . 'sitenav2_amount']; $s++) {
.....
}
}

I guess I am just confused as to why they are no longer printed in the original order when collapsed.

So we got the order of

Link0
Link1
Link1 sub 0
Link1 sub 1
Link2
etc....
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Collapse navlink config under heading in backend

Post by Timbalu »

I start to get confused... ;-)

In addition to my last post:
$template config array and $template_loaded_config array are different. The last is a 1-level array and looks like:

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] => #
    .......
}
not supporting the keys, like the first one 2-level array has.

My small foreach loop to collect the navlinks out of the last array, matches the assoc keys to hold the keynames in a new array [] =>'keynamevalue'. This one is then given to the magic grouping method, which needs the 'var' names 'sidebars', 'webfonts', etc, to build that collapsable output.

Yes, I am sure it is necessary for you have to have the 'content' part titles inside that array too. But as I said, this need some extra work, which I am not sure will work out easy.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Collapse navlink config under heading in backend

Post by Don Chambers »

Here is a new twist... In your example, can the resulting $navonly be emitted within an existing heading such as 'My Heading' => array('colorset', 'userstylesheet', etc.....)?
=Don=
Post Reply