Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Petter B - tammikuu 29, 2014, 02:04:16 AP

Otsikko: A collapsable navigation menu
Kirjoitti: Petter B - tammikuu 29, 2014, 02:04:16 AP
I would like to have a collapsable navigation menu in a side block, showing categories, boards and sub-boards.
Does anyone know how to do this?
The best would be if "opened" categories in the tree stayed opened even if page is reloaded or person is surfing around the forum.

Se attached.

I would be very thankful for any kind of help, and can also pay someone for fixing this for me.
Otsikko: Re: A collapsable navigation menu
Kirjoitti: kat - tammikuu 29, 2014, 05:56:20 AP
A Simple Portal block, perhaps? Either custom php or custom html?
Otsikko: Re: A collapsable navigation menu
Kirjoitti: Petter B - tammikuu 30, 2014, 01:25:03 AP
Yes, but what would the php/html be?
:)
Otsikko: Re: A collapsable navigation menu
Kirjoitti: kat - tammikuu 30, 2014, 05:19:16 AP
Er... Pass. :(
Otsikko: Re: A collapsable navigation menu
Kirjoitti: margarett - tammikuu 30, 2014, 06:27:28 AP
Check the code in Sources/BoardIndex.php:


// Retrieve the categories and boards.
require_once($sourcedir . '/Subs-BoardIndex.php');
$boardIndexOptions = array(
'include_categories' => true,
'base_level' => 0,
'parent_id' => 0,
'set_latest_post' => true,
'countChildPosts' => !empty($modSettings['countChildPosts']),
);
$context['categories'] = getBoardIndex($boardIndexOptions);

Use your own variable instead of $context['categories']. This even nicer because it already deals with user permissions, so each one will only see the adequate content ;)

Then use a "foreach" cycle in it and echo the relevant information. Style is as you with and there 'ya go ;)
Otsikko: Re: A collapsable navigation menu
Kirjoitti: Petter B - helmikuu 21, 2014, 06:40:37 IP
Thank you Margarett.  :)
It sounds good with the user permissions.
Unfortunately, I don´t know php and have no clue on what to put in the Simpleportal php-block... :-[
Otsikko: Re: A collapsable navigation menu
Kirjoitti: margarett - helmikuu 21, 2014, 07:07:10 IP
Unfortunately I never used SP (or other portal, for what matters). I'd have to look into in big deep and I don't have the time to do so now :(

As far as I remember on this subject (my memory fails on me :P ) I think you should reproduce the behavior of the standard code of BoardIndex and then style it to your needs (ie, if on current board, show sub-boards, etc).
While this is doable (everything is, as long as it is coded :P ) it represents a non-trivial amount of work to accomplish :(
Otsikko: Re: A collapsable navigation menu
Kirjoitti: TheListener - helmikuu 21, 2014, 07:09:41 IP
You can do this on SP by way of a portal block and pages.

@OP please use the mods support topic or better still www.simpleportal.net :)
Otsikko: Re: A collapsable navigation menu
Kirjoitti: Petter B - helmikuu 22, 2014, 07:40:00 AP
Lainaus käyttäjältä: margarett - helmikuu 21, 2014, 07:07:10 IP
As far as I remember on this subject (my memory fails on me :P ) I think you should reproduce the behavior of the standard code of BoardIndex and then style it to your needs (ie, if on current board, show sub-boards, etc).
While this is doable (everything is, as long as it is coded :P ) it represents a non-trivial amount of work to accomplish :(

Yes, this would be a good solution, but probably with too much work.
I think I´ll go for hardcoded links to the categories/boards. But how do I make it collapseble?  :-[  Is there a code snippet for a collapseble nav menu somewhere I can just paste the boardnames and urls into? Like in attached image of first post?

Lainaus käyttäjältä: Old Fossil - helmikuu 21, 2014, 07:09:41 IP
You can do this on SP by way of a portal block and pages.

I don´t understand... :-[
I have been thinking of blocks (one for each category) in a block, is that you mean?

Lainaa
@OP please use the mods support topic or better still www.simpleportal.net :)

I have asked att SP here (http://simpleportal.net/index.php?topic=13002.0) and here (http://simpleportal.net/index.php?topic=13150.0), but no answer. Sorry if it´s not the right place to ask here, I thought a code like this could be interesting even for people not using SP.   :)
Otsikko: Re: A collapsable navigation menu
Kirjoitti: feline - helmikuu 22, 2014, 01:32:03 IP
That what you want, you can find on the PortaMx Portal ..
the block is called as CBT Naviagator .. CBT = Category - Board - Topic.
Otsikko: Re: A collapsable navigation menu
Kirjoitti: Petter B - helmikuu 22, 2014, 02:26:38 IP
Lainaus käyttäjältä: feline - helmikuu 22, 2014, 01:32:03 IP
That what you want, you can find on the PortaMx Portal ..
the block is called as CBT Naviagator .. CBT = Category - Board - Topic.


Is it possible to use the code in a Simpleportal php-block? It´s not an option for me to switch portal now.
Otsikko: Re: A collapsable navigation menu
Kirjoitti: margarett - helmikuu 23, 2014, 02:44:48 IP
This should help you:
http://simpleportal.net/index.php?topic=1532.msg46971#msg46971

The code isn't compatible with SMF2 but a simple change to use $smcFunc should (probably :P ) get you there.
Otsikko: Re: A collapsable navigation menu
Kirjoitti: Petter B - maaliskuu 02, 2014, 10:35:16 AP
Thanks. Unfortunately it doesn´t seem to work with the new SP version either. I think I´ll go for hardcoded links. Does anyone know how to make expandable nav trees like this:
Otsikko: Re: A collapsable navigation menu
Kirjoitti: margarett - maaliskuu 02, 2014, 04:06:00 IP
Unfortunately it's not direct. You need to get the boards list and rebuilt it with parent/child relations. When you're showing a parent, then present it open. Otherwise show it closed