SimplePortal

Customization => Blocks and Modifications => Topic started by: Nathaniel on February 21, 2009, 07:20:40 AM

Title: SP Navigation Block.
Post by: Nathaniel on February 21, 2009, 07:20:40 AM
Information:
The attached mod will install the SP Forum Navigation Block.

SimplePortal MUST be installed, you can download it here (http://simpleportal.net/index.php?action=download).

Make sure that you uninstall this mod before uninstalling SimplePortal. If you don't then errors may occur.

SimplePortal block created by LHVWB.

Versions:
1.00:  Created/Tested for SMF 1.1.8/2 RC1 and SP 2.1.1.
1.01:  Created/Tested for SMF 1.1.8/2 RC1 and SP 2.2.

You can easily customize the appearance of this block in two ways.
1) You can add some css to the end of your themes 'style.css' file that uses the 'sp_navigation_block_cat' and 'sp_navigation_block_board' classes.
Code: (Example) [Select]
/* This css code changes the SP Forum Navigation Block styles. */
.sp_navigation_block_cat a
{
font-size: 15px;
color: #00DDDD;
}
.sp_navigation_block_board a
{
font-size: 12px;
color: blue;
}
Attached are examples of how this block looks before and after that css is applied.

2) Do a search for the code below in your 'SPortalX.php' file (it should be very close to the end of the file; replace the 'X' with '2' or '1-1' depending on your forum version).
Code: [Select]
$prefix .= '-';
You can change the '-' value to customize the symbol/image/html that is used to separate categories from boards and boards from their child boards.

For SP 2.2 versions and above, this code will add a random colored 'dot':
Code: [Select]
$prefix .= sp_embed_image('dot');
Title: Re: [Mod] SP Navigation Block.
Post by: dabeer on February 21, 2009, 03:02:42 PM
a very nice mod, thank you!
Title: Re: [Mod] SP Navigation Block.
Post by: KahneFan on February 21, 2009, 04:01:49 PM
It might be nice to have an extra break between the last board of a category and the next category title. Where might I go to add that, if possible?

In your example...

New Category
 - New Board
General Category
 - General Discussion

Would be...
New Category
 - New Board

General Category
 - General Discussion

I guess I could adjust it with margin in the CSS?
Title: Re: [Mod] SP Navigation Block.
Post by: Nathaniel on February 21, 2009, 07:01:37 PM
You should be able to do it with css, but if you want to edit the function itself then ydo a search for the 'sp_forum_navigation' funcion at the very bottom of you 'SPortalX.php' file (replace X with forum version, ie '1-1' or '2').

Replace this code:
Code: [Select]
echo '
', $prefix, '<span class="sp_navigation_block_board"><a href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a></span><br />';
}

With this code:
Code: [Select]
echo '
', $prefix, '<span class="sp_navigation_block_board"><a href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a></span><br />';
}
echo '<br />';
}
Title: Re: [Mod] SP Navigation Block.
Post by: KahneFan on February 22, 2009, 02:08:47 AM
Again, thank you very much!!
Title: Re: [Mod] SP Navigation Block.
Post by: KahneFan on April 02, 2009, 01:19:38 PM
Any chance you would upgrade this for 2.2? I was surprised that 2.2 used the top navi bar for their menu box instad of this style navi box.
Title: Re: [Mod] SP Navigation Block.
Post by: Nathaniel on April 02, 2009, 04:48:08 PM
Noted, I will do an update for 2.2 sometime.
Title: Re: [Mod] SP Navigation Block.
Post by: Nathaniel on April 08, 2009, 03:06:22 AM
Updated this mod.

Version 1.01 is compatible with SP 2.2.
Title: Re: [Mod] SP Navigation Block.
Post by: KahneFan on April 08, 2009, 12:11:18 PM
I was missing this block very much, thanks!!  :D
Title: Re: [Mod] SP Navigation Block.
Post by: Geri on April 15, 2009, 06:40:24 AM
I was missing this block very much, thanks!!  :D

The same here. :)
Thanks LHVWB
Title: Re: [Mod] SP Navigation Block.
Post by: xxnine on June 02, 2009, 04:45:43 AM
a very nice mod, thank you!
Title: Re: SP Navigation Block.
Post by: KahneFan on June 12, 2009, 09:14:26 PM
Any chance for a 2.2.2 update?
Title: Re: SP Navigation Block.
Post by: Nathaniel on June 12, 2009, 10:10:14 PM
@KahneFan,
I haven't tried it with 2.2.2, but it should still work...
Title: Re: SP Navigation Block.
Post by: KahneFan on June 12, 2009, 10:43:06 PM
I used the 2.2.2 upgrade feature and when I looked at my portal it was throwing an error... and no... I didn't copy it, sorry :(
Title: Re: SP Navigation Block.
Post by: Nathaniel on June 13, 2009, 12:19:13 AM
The SP 2.2.2 overwrites some of the files that this block/mod edits. If you uninstall and then reinstall the mod then the issue should go away.
Title: Re: SP Navigation Block.
Post by: KahneFan on June 13, 2009, 12:32:01 AM
Gotcha. Thanks!

So, next time I upgrade SP:

1) Uninstall this mod
2) Install/upgrade SP
3) Reinstall this mod
Title: Re: SP Navigation Block.
Post by: lucrece on July 22, 2009, 03:06:07 PM
installed this mod but nothing seems to happen. should I see it? what's going on?
Title: Re: SP Navigation Block.
Post by: ???1031 on July 23, 2009, 06:26:19 AM
Look at the Add Block there is a new block =).
Title: Re: SP Navigation Block.
Post by: Pete.Bennett on August 25, 2009, 07:20:39 AM
Hi there, I'd like to download a copy of this mod but the download link is not working. Is it still available please?

Thanks

Pete
Title: Re: SP Navigation Block.
Post by: SPARK on September 02, 2009, 07:28:15 PM
Hey guys just upgraded to 2.3 and went to install this mod again and it show a heap of errors.

can some please help.
Title: Re: SP Navigation Block.
Post by: SPARK on September 11, 2009, 07:16:28 AM
?? anyone want to help?
Title: Re: SP Navigation Block.
Post by: SPARK on September 23, 2009, 06:47:24 AM
Still nothing? please can someone take a look i love this block it makes it so easy to get around.
Title: Re: SP Navigation Block.
Post by: goldwinggl on November 22, 2009, 05:51:26 PM
I get this when i try to apply mod...

Installing this package will perform the following actions:
   Type    Action    Description
1.    Execute Modification    ./Sources/SPortal1-1.php    File not found
2.    Execute Modification    ./Themes/default/languages/SPortal.english.php    Test failed
3.    Execute Modification    ./Themes/default/languages/SPortal.english-utf8.php    Test failed
4.    Execute Modification    ./Themes/default/languages/SPortalHelp.english.php    Test successful
5.    Execute Modification    ./Themes/default/languages/SPortalHelp.english-utf8.php    Test successful
6.    Execute Code    install1.php
Title: Re: SP Navigation Block.
Post by: ccbtimewiz on November 22, 2009, 06:03:54 PM
The mod is outdated. It will need to be updated.
Title: Re: SP Navigation Block.
Post by: hybrid on December 27, 2009, 05:28:25 AM
how i do this on 1.1.11?
and please explain me where because im kinda new in this.
Title: Re: SP Navigation Block.
Post by: hybrid on December 27, 2009, 12:08:57 PM
i dont get it where do i place it?
Title: Re: SP Navigation Block.
Post by: trlxpro on February 07, 2010, 12:15:28 AM
i dont get it where do i place it?

dude, just search google for css vertical menu coding. find a script, add the links you want, an make a html portal [block] and copy and paste the code in there...

this way you can direct them anywhere, and have your own colors to match ur site..

(http://i256.photobucket.com/albums/hh187/implicit_album/lillinkscssmenu.png)



Title: Re: SP Navigation Block.
Post by: Oskarlover on February 12, 2010, 03:44:58 AM
Is this gonna work with 2.0 RC2 ?
Title: Re: SP Navigation Block.
Post by: dtek on March 15, 2010, 09:50:21 AM
I get this when i try to apply mod...

Installing this package will perform the following actions:
   Type    Action    Description
1.    Execute Modification    ./Sources/SPortal1-1.php    File not found
2.    Execute Modification    ./Themes/default/languages/SPortal.english.php    Test failed
3.    Execute Modification    ./Themes/default/languages/SPortal.english-utf8.php    Test failed
4.    Execute Modification    ./Themes/default/languages/SPortalHelp.english.php    Test successful
5.    Execute Modification    ./Themes/default/languages/SPortalHelp.english-utf8.php    Test successful
6.    Execute Code    install1.php



Me too. Can we get some help with this please?
Title: Re: SP Navigation Block.
Post by: ccbtimewiz on March 15, 2010, 04:04:38 PM
The mod is outdated. It will need to be updated.
Title: Re: SP Navigation Block.
Post by: johanlm on May 18, 2010, 11:37:00 AM
Interested in this to. Is it left for dead or is it a matter of lack of time?
Title: Re: SP Navigation Block.
Post by: Nathaniel on May 19, 2010, 02:58:23 AM
Working on the SimplePortal core has a much higher precedence than this mod atm. ;)
Title: Re: SP Navigation Block.
Post by: johanlm on May 21, 2010, 02:44:47 PM
pfft ... lame excuse.  8)
Title: Re: SP Navigation Block.
Post by: zapiy on September 13, 2010, 03:58:34 PM
Does this work on the latest version?
Title: Re: SP Navigation Block.
Post by: james-at on May 18, 2011, 04:39:27 AM
SP Navigation Block for SimplePortal 2.3.3 (Updated by me)

1. Go to Blocks > Add block > Custom Php Code >
2. Paste the next code:

Code: [Select]
global $cat_tree, $boards, $boardList, $scripturl, $sourcedir, $user_info, $db_prefix;

$block_parameters = array(
'num_children' => 'int',
);

if ($return_parameters)
return $block_parameters;

$child_depth = !empty($parameters['num_children']) ? (int) $parameters['num_children'] - 1 : -1;

require_once($sourcedir . '/Subs-Boards.php');
getBoardTree();

// Remobe any boards this user can't actually see.
$temp_boards = $boards;
$request = db_query("
SELECT b.ID_BOARD
FROM {$db_prefix}boards AS b
WHERE !($user_info[query_see_board])", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
unset($temp_boards[$row['ID_BOARD']]);
mysql_free_result($request);

echo '
<div style="padding-left:2px;">';

foreach ($cat_tree as $catid => $tree)
{
echo '
<span class="sp_navigation_block_cat" style="font-weight:bold;"><a href="', $scripturl, '?action=forum#', $tree['node']['id'], '">', $tree['node']['name'], '</a></span><br />';

foreach ($boardList[$catid] as $boardid)
{


$prefix = '';
for ($i=0; $i<=$boards[$boardid]['level']; $i++)
$prefix .= '-';

echo '
', $prefix, '<span class="sp_navigation_block_board"><a href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a></span><br />';
}
}

echo '
</div>';

This work pefectly. Check my portal: http://www.darksitel.com/index.php

Regards.
Title: Re: SP Navigation Block.
Post by: agent47 on June 29, 2011, 06:43:34 AM
SP Navigation Block for SimplePortal 2.3.3 (Updated by me)
Doesn't work on my site which runs on SMF 2.0 though. I get this error:
Code: [Select]
Fatal error: Call to undefined function db_query() in /home/xxxxx/public_html/Sources/PortalBlocks.php(3351) : eval()'d code on line 17
I'm guessing it isn't written for SMF 2.0.
Title: Re: SP Navigation Block.
Post by: velorooms on October 29, 2012, 03:40:43 PM
same error here
Title: Re: SP Navigation Block.
Post by: iobit on February 09, 2013, 01:52:34 AM
Any update for SP 2.3.5?

Thanks
Title: Re: SP Navigation Block.
Post by: Petter on March 02, 2014, 10:30:43 AM
Does anyone use this with SP 2.3.5?
Title: Re: SP Navigation Block.
Post by: [SiNaN] on March 04, 2014, 03:19:59 PM
Here's a basic one that would work with SMF 2.x versions and any version of SimplePortal that supports it:

Code: [Select]
global $cat_tree, $boards, $boardList, $scripturl, $sourcedir, $smcFunc;

require_once($sourcedir . '/Subs-Boards.php');

getBoardTree();

$temp_boards = $boards;

$request = $smcFunc['db_query']('', '
SELECT b.id_board
FROM {db_prefix}boards AS b
WHERE !({query_see_board})');
while ($row = $smcFunc['db_fetch_assoc']($request))
unset($temp_boards[$row['id_board']]);
$smcFunc['db_free_result']($request);

echo '
<ul>';

foreach ($cat_tree as $catid => $tree)
{
echo '
<li><a href="', $scripturl, '?action=forum#c', $tree['node']['id'], '">', $tree['node']['name'], '</a>';

if (!empty($boardList[$catid]))
{
echo '<ul>';

foreach ($boardList[$catid] as $key => $boardid)
{
if (empty($temp_boards[$boardid]))
continue;

$current_level = $boards[$boardid]['level'];
$next_level = isset($boardList[$catid][$key + 1]) ? $boards[$boardList[$catid][$key + 1]]['level'] : -1;

echo '
<li><a href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a>', $next_level > $current_level ? ' <span onclick="document.getElementById(\'spcatexpand' . $boardid . '\').style.display = \'\';">+</span>' : '';

if ($next_level > $current_level)
echo '<ul style="display: none;" id="spcatexpand', $boardid, '">';
else
echo '</li>';

if ($next_level < $current_level && $current_level != 0)
echo '</ul></li>';
elseif ($next_level < $current_level)
echo '</li>';
}

echo '</ul>';
}

echo '</li>';
}

echo '</ul>';

It may not look the best as far as the styling goes but you have unordered lists there, so feel free to style it as you wish using CSS.
Title: Re: SP Navigation Block.
Post by: Petter on March 05, 2014, 01:07:37 AM
Wow, thanks  :D
It works perfectly, but I didn´t realize I had that many boards, it became a very lock block... ;P


I have been thinking of making this nav block with hardcoded links to the boards & cats, and last night I found a very nice JQuery plugin for making a collapsable menu.
See demo: http://apps.komposta.net/jquery/navgoco/demo/
Tutorial: http://www.komposta.net/article/navgoco


Would that be possible to use in a SP block and if so, how?
Either with hardcoded links or better: in combination with the code you´ve made above?


Thank you very much for helping us all out with our problems and wishes  :-*
Title: Re: SP Navigation Block.
Post by: [SiNaN] on March 06, 2014, 08:25:49 AM
As I said, it's very easy to customize because it just uses unordered lists. Here's the code (only modified a little) to make it work with that JQuery plugin:

Add the necessary includes between the <head></head> tags in index.template.php file of your theme. It should look something like the following:

Code: [Select]
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="http://apps.komposta.net/jquery/navgoco/src/jquery.cookie.js"></script>
<script type="text/javascript" src="http://apps.komposta.net/jquery/navgoco/src/jquery.navgoco.js"></script>
<link rel="stylesheet" href="http://apps.komposta.net/jquery/navgoco/src/jquery.navgoco.css" type="text/css" media="screen" />

Use the following in a Custom PHP block:

Code: [Select]
global $cat_tree, $boards, $boardList, $scripturl, $sourcedir, $smcFunc;

require_once($sourcedir . '/Subs-Boards.php');

getBoardTree();

$temp_boards = $boards;

$request = $smcFunc['db_query']('', '
SELECT b.id_board
FROM {db_prefix}boards AS b
WHERE !({query_see_board})');
while ($row = $smcFunc['db_fetch_assoc']($request))
unset($temp_boards[$row['id_board']]);
$smcFunc['db_free_result']($request);

echo '
<ul class="nav">';

foreach ($cat_tree as $catid => $tree)
{
echo '
<li><a href="', $scripturl, '?action=forum#c', $tree['node']['id'], '">', $tree['node']['name'], '</a>';

if (!empty($boardList[$catid]))
{
echo '<ul>';

foreach ($boardList[$catid] as $key => $boardid)
{
if (empty($temp_boards[$boardid]))
continue;

$current_level = $boards[$boardid]['level'];
$next_level = isset($boardList[$catid][$key + 1]) ? $boards[$boardList[$catid][$key + 1]]['level'] : -1;

echo '
<li><a href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a>';

if ($next_level > $current_level)
echo '<ul>';
else
echo '</li>';

if ($next_level < $current_level && $current_level != 0)
echo '</ul></li>';
elseif ($next_level < $current_level)
echo '</li>';
}

echo '</ul>';
}

echo '</li>';
}

echo '</ul>
<script type="text/javascript">
$(document).ready(function() {
$(".nav").navgoco();
});
</script>';

Have fun!
Title: Re: SP Navigation Block.
Post by: Petter on March 07, 2014, 09:41:33 AM
Thanks, I must have done something wrong. The boards show in the block, a bit different, but no collapsable tree.
I tried upload the plugin files to root-folder and changing the urls in index.template.php but no difference.
Title: Re: SP Navigation Block.
Post by: [SiNaN] on March 07, 2014, 09:53:07 AM
Yeah, you probably did something wrong, as I tested it before posting and it was working fine. Are you sure the code you put in the header is correct? (the URLs for the scripts) You can test this by using the code above, which relies on the demo site you gave the link to.
Title: Re: SP Navigation Block.
Post by: Petter on March 10, 2014, 06:14:07 AM
Yes, I think I made it right, but maybe you can have a look att the attached file?

The demo works fine on my server: http://dev.alternativ.nu/demo/index.html (http://dev.alternativ.nu/demo/index.html)

P.S the plugin is now updated for clickable parents, does anything need to be changed in the code?
Title: Re: SP Navigation Block.
Post by: kimyaci on March 13, 2014, 08:53:19 PM
Thanks for the navigation block.One gives xhtml errors.I would be glad if you correct this error.Hidden categories and boards, it would be better not to view in the navigation menu.Thanks.

You can look at my site for the error.

http://www.igo8navigation.com/index.php
Title: Re: SP Navigation Block.
Post by: Chen Zhen on March 13, 2014, 09:17:16 PM

kimyaci,

  Most of your errors shown on that page are from improper attributes added to img tags. No one has supplied any block in this thread containing images. This appears to be something customized on your site that was done improperly but not related to any post here.

Regards.
Title: Re: SP Navigation Block.
Post by: kimyaci on March 13, 2014, 09:30:47 PM
When I remove the navigation block, the error message disappears.Thank you for your answer.

Regards

Error Message;
Code: [Select]
Line 2821, Column 83: end tag for "ul" which is not finished

…ref="http://www.igo8navigation.com/forum#c14">Private Section</a><ul></ul></li>
Title: Re: SP Navigation Block.
Post by: Chen Zhen on March 13, 2014, 11:45:43 PM
kimyaci,

You can try this block to see if it corrects the specific issue you reported:

Code: [Select]
global $cat_tree, $boards, $boardList, $scripturl, $sourcedir, $smcFunc;

require_once($sourcedir . '/Subs-Boards.php');

getBoardTree();

$temp_boards = $boards;

$request = $smcFunc['db_query']('', '
SELECT b.id_board
FROM {db_prefix}boards AS b
WHERE !({query_see_board})');

while ($row = $smcFunc['db_fetch_assoc']($request))
unset($temp_boards[$row['id_board']]);

$smcFunc['db_free_result']($request);

if (!empty($cat_tree))
echo '
<ul class="nav">';

foreach ($cat_tree as $catid => $tree)
{
echo '
<li>
<a href="', $scripturl, '?action=forum#c', $tree['node']['id'], '">', $tree['node']['name'], '</a>';

if (!empty($boardList[$catid]))
{
echo '
<ul>';

foreach ($boardList[$catid] as $key => $boardid)
{
if (empty($temp_boards[$boardid]))
continue;

$current_level = $boards[$boardid]['level'];
$next_level = isset($boardList[$catid][$key + 1]) ? $boards[$boardList[$catid][$key + 1]]['level'] : -1;

echo '
<li>
<a href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a>';

if ($next_level > $current_level)
echo '
<ul>';
else
echo '
</li>';

if ($next_level < $current_level && $current_level != 0)
echo '
</ul>
</li>';
elseif ($next_level < $current_level)
echo '
</li>';
}

echo '
</ul>';
}

echo '</li>';
}

if (!empty($cat_tree))
echo '
</ul>';

echo '
<script type="text/javascript">
$(document).ready(function() {
$(".nav").navgoco();
});
</script>';
Title: Re: SP Navigation Block.
Post by: kimyaci on March 14, 2014, 06:20:44 AM
One got error message.Thanks.

Error Line 2791, Column 7: end tag for "ul" which is not finished

      </ul></li>
Title: Re: SP Navigation Block.
Post by: Chen Zhen on March 14, 2014, 09:33:05 AM

kimyaci,

Try this out:
Code: [Select]
global $cat_tree, $boards, $boardList, $scripturl, $sourcedir, $smcFunc;

require_once($sourcedir . '/Subs-Boards.php');

getBoardTree();

$temp_boards = $boards;

$request = $smcFunc['db_query']('', '
SELECT b.id_board
FROM {db_prefix}boards AS b
WHERE !({query_see_board})');

while ($row = $smcFunc['db_fetch_assoc']($request))
unset($temp_boards[$row['id_board']]);

$smcFunc['db_free_result']($request);

if (!empty($cat_tree))
echo '
<ul class="nav">';

foreach ($cat_tree as $catid => $tree)
{
echo '
<li>
<a href="', $scripturl, '?action=forum#c', $tree['node']['id'], '">', $tree['node']['name'], '</a>';

if (!empty($boardList[$catid]))
{
echo '
<ul>';

foreach ($boardList[$catid] as $key => $boardid)
{
if (empty($temp_boards[$boardid]))
continue;

$current_level = $boards[$boardid]['level'];
$next_level = isset($boardList[$catid][$key + 1]) ? $boards[$boardList[$catid][$key + 1]]['level'] : -1;

echo '
<li>
<a href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a>';

if ($next_level > $current_level)
echo '
<ul>';
else
echo '
</li>';

if ($next_level < $current_level && $current_level != 0)
echo '
</ul>
</li>';
elseif ($next_level > $current_level)
echo '
</li>';
}

echo '
</ul>';
}

echo '</li>';
}

if (!empty($cat_tree))
echo '
</ul>';

echo '
<script type="text/javascript">
$(document).ready(function() {
$(".nav").navgoco();
});
</script>';
Title: Re: SP Navigation Block.
Post by: kimyaci on March 14, 2014, 09:59:29 AM
Sorry, but gave 202 error message.Thanks.
Title: Re: SP Navigation Block.
Post by: Chen Zhen on March 14, 2014, 02:32:17 PM
kimyaci,

  My validator does not show any errors for the last code provided.
Title: Re: SP Navigation Block.
Post by: kimyaci on March 15, 2014, 05:36:11 AM
kimyaci,

  My validator does not show any errors for the last code provided.

Ok.Thank you very much.
Title: Re: SP Navigation Block.
Post by: [SiNaN] on March 15, 2014, 10:10:01 AM
Yes, I think I made it right, but maybe you can have a look att the attached file?

The demo works fine on my server: http://dev.alternativ.nu/demo/index.html (http://dev.alternativ.nu/demo/index.html)

P.S the plugin is now updated for clickable parents, does anything need to be changed in the code?

Any chance that you add the block and make it visible for guests, so I can test it myself?
Title: Re: SP Navigation Block.
Post by: Petter on March 16, 2014, 02:51:22 PM
Any chance that you add the block and make it visible for guests, so I can test it myself?



That would be very kind. It´s the top block in the right column at http://dev.alternativ.nu (http://dev.alternativ.nu) called "Träd".
Title: Re: SP Navigation Block.
Post by: Chen Zhen on March 16, 2014, 04:55:58 PM
Petter,

  Try moving the javascript codes directly prior to </head> ...

ie.
Code: [Select]
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="http://apps.komposta.net/jquery/navgoco/src/jquery.cookie.js"></script>
<script type="text/javascript" src="http://apps.komposta.net/jquery/navgoco/src/jquery.navgoco.js"></script>
<link rel="stylesheet" href="http://apps.komposta.net/jquery/navgoco/src/jquery.navgoco.css" type="text/css" media="screen" />
</head>

  Failing that, try it in the SMF default theme (add script codes to its template) to see if the javascript that your custom theme is using is conflicting somehow.

Title: Re: SP Navigation Block.
Post by: Petter on March 17, 2014, 05:16:26 AM
Sorry, it did not work... I tried both.
Title: Re: SP Navigation Block.
Post by: Chen Zhen on March 17, 2014, 06:31:28 PM
  Remove the edits to any theme template files. When you apply the following code within a PHP block, adjust the colors in the array at the top to your preference for aesthetics. 

  I found the provided colors did not look proper for some dark themes else the dynamic css may not be working. If the dynamic css is not working, I can manually add the attributes via style tags and omit the dynamic css file.


  If this does not work for you (although it should), another option is to create 3 js files with the necessary content, put them into the default theme css folder and load them locally.  Those files can then be edited if necessary (concerning css).

Code: [Select]
// Set the custom text colors within the array (this may be necessary for custom themes)
$customTextColors = array(
'board' => 'blue',
'child' => 'gray',
'bullet' => 'red'
);

echo '
<script type="text/javascript">
var link = document.createElement("link");
link.href = "http://apps.komposta.net/jquery/navgoco/src/jquery.navgoco.css";
link.rel = "stylesheet";
link.type = "text/css";
link.media = "screen";
document.getElementsByTagName("head")[0].appendChild(link);
document.write(\'<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"><\/script>\');
document.write(\'<script type="text/javascript" src="http://apps.komposta.net/jquery/navgoco/src/jquery.cookie.js"><\/script>\');
document.write(\'<script type="text/javascript" src="http://apps.komposta.net/jquery/navgoco/src/jquery.navgoco.js"><\/script>\');
</script>';

global $cat_tree, $boards, $boardList, $scripturl, $sourcedir, $smcFunc;

require_once($sourcedir . '/Subs-Boards.php');

getBoardTree();

$temp_boards = $boards;

$request = $smcFunc['db_query']('', '
SELECT b.id_board
FROM {db_prefix}boards AS b
WHERE !({query_see_board})');

while ($row = $smcFunc['db_fetch_assoc']($request))
unset($temp_boards[$row['id_board']]);

$smcFunc['db_free_result']($request);

if (!empty($cat_tree))
echo '
<ul id="mymenu2" class="nav">';

foreach ($cat_tree as $catid => $tree)
{
echo '
<li>
<a style="color:', $customTextColors['bullet'], ';" href="', $scripturl, '?action=forum#c', $tree['node']['id'], '"><strong style="display:inline-block;color:', $customTextColors['board'], ';">', $tree['node']['name'], '</strong></a>';

if (!empty($boardList[$catid]))
{
echo '
<ul>';

foreach ($boardList[$catid] as $key => $boardid)
{
if (empty($temp_boards[$boardid]))
continue;

$current_level = $boards[$boardid]['level'];
$next_level = isset($boardList[$catid][$key + 1]) ? $boards[$boardList[$catid][$key + 1]]['level'] : -1;

echo '
<li>
<a style="color:', $customTextColors['child'], ';" href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a>';

if ($next_level > $current_level)
echo '
<ul>';
else
echo '
</li>';

if ($next_level < $current_level && $current_level != 0)
echo '
</ul>
</li>';
elseif ($next_level > $current_level)
echo '
</li>';
}

echo '
</ul>';
}

echo '</li>';
}

if (!empty($cat_tree))
echo '
</ul>';

echo '
<script type="text/javascript">
$(document).ready(function() {
    $("#mymenu2").navgoco({accordion: true});
});
</script>';

Regards.
Title: Re: SP Navigation Block.
Post by: Petter on March 18, 2014, 02:29:39 AM
Yes!(http://www.alternativ.nu/petter/yess.gif)
Works perfect, now I only need to adjust the colors.
Many many thanks!
Title: Re: SP Navigation Block.
Post by: Petter on March 18, 2014, 08:17:20 AM
This is now a great block that I can recommend. :)


If someone find it useful, I found out that:

-If you don´t want the parents (categories) to be clickable, just opening, find:
Code: [Select]
<a style="color:', $customTextColors['bullet'], ';" href="', $scripturl, '?action=forum#c', $tree['node']['id'], '"><strong style="display:inline-block;color:', $customTextColors['board'], ';">', $tree['node']['name'], '</strong></a>';
Replace with:
Code: [Select]
<a style="color:', $customTextColors['bullet'], ';" href="#"><strong style="display:inline-block;color:', $customTextColors['board'], ';">', $tree['node']['name'], '</strong></a>';

-If you don´t want opened parent to close automatically when opening another, find:
Code: [Select]
    $("#mymenu2").navgoco({accordion: true});Replace with:
Code: [Select]
    $("#mymenu2").navgoco({accordion: false});

--------------

Two things I have not found out is:
- where the small arrows are and how to edit the look of them.
- how to place them on the left side. "Float: left;" makes them push the link to the right. (attaching css file)
Title: Re: SP Navigation Block.
Post by: Chen Zhen on March 19, 2014, 12:27:26 AM
Petter,

New custom PHP block code:
Code: [Select]
global $cat_tree, $boards, $boardList, $scripturl, $sourcedir, $smcFunc, $settings;

// Set the custom text colors within the array (this may be necessary for custom themes)
$customTextColors = array(
'board' => 'white',
'child' => 'gray',
'bullet' => 'red'
);

echo '
<script type="text/javascript">
var link = document.createElement("link");
link.href = "', $settings['default_theme_url'], '/css/jquery.navgoco.css";
link.rel = "stylesheet";
link.type = "text/css";
link.media = "screen";
document.getElementsByTagName("head")[0].appendChild(link);
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="http://apps.komposta.net/jquery/navgoco/src/jquery.cookie.js"></script>
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/jquery.navgoco.js"></script>';

require_once($sourcedir . '/Subs-Boards.php');

getBoardTree();

$temp_boards = $boards;

$request = $smcFunc['db_query']('', '
SELECT b.id_board
FROM {db_prefix}boards AS b
WHERE !({query_see_board})');

while ($row = $smcFunc['db_fetch_assoc']($request))
unset($temp_boards[$row['id_board']]);

$smcFunc['db_free_result']($request);

if (!empty($cat_tree))
echo '
<ul id="mynavgoco_menu" class="nav">';

foreach ($cat_tree as $catid => $tree)
{
echo '
<li>
<a class="navgoco_xlinks" id="', $catid, '" style="color:', $customTextColors['bullet'], ';" href="', $scripturl, '?action=forum#c', $tree['node']['id'], '"><strong style="display:inline-block;color:', $customTextColors['board'], ';">', $tree['node']['name'], '</strong></a>';

if (!empty($boardList[$catid]))
{
echo '
<ul>';

foreach ($boardList[$catid] as $key => $boardid)
{
if (empty($temp_boards[$boardid]))
continue;

$current_level = $boards[$boardid]['level'];
$next_level = isset($boardList[$catid][$key + 1]) ? $boards[$boardList[$catid][$key + 1]]['level'] : -1;

echo '
<li>
<a style="color:', $customTextColors['child'], ';" href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a>';

if ($next_level > $current_level)
echo '
<ul>';
else
echo '
</li>';

if ($next_level < $current_level && $current_level != 0)
echo '
</ul>
</li>';
elseif ($next_level > $current_level)
echo '
</li>';
}

echo '
</ul>';
}

echo '</li>';
}

if (!empty($cat_tree))
echo '
</ul>';

echo '
<script type="text/javascript">
$(document).ready(function() {
    $("#mymenu2").navgoco({accordion: true});
});
</script>';

  I attached 4 files that you can place in the following directories:


  The files named navgoco_expand.gif & navgoco_collapse.gif are just copies of their equivalents from the default theme. You can change them to your own images whereas you just use the same file names & type (unless you want to edit the jquery.navgoco.js file to change the names).

  I used some javascript to toggle the images although it can be done via the css file if preferred.
Try it out and let me know if it works for you.

Regards.



Title: Re: SP Navigation Block.
Post by: Chen Zhen on March 24, 2014, 11:12:14 PM
Petter,

  Omit any edits, files and/or blocks concerning the Navgoco Menu and install the custom portal plugin from:
http://simpleportal.net/index.php?topic=13278.0

Regards.
 
Title: Re: SP Navigation Block.
Post by: Petter on March 25, 2014, 12:10:24 PM
Wow, that´s truly a great plugin you made!
Works like a charm. Unfortunatly I might not use it since I may put the nav-tree in a jquery mobile Panel instead of SP and in that case I´ll use the code you helped me with before.
One thing I haven´t figured out: how do I make parentboards not clickable, just opening submenu? See, my parentboards are empty.
I made this successfully with the categories by making href="#", doing the same to the parentboards opens the submenu correct without going to the board, but then the childboards are not clickable...


Title: Re: SP Navigation Block.
Post by: Chen Zhen on March 26, 2014, 06:08:52 PM
Petter,

  You can still use updated versions of this plugin by installing the plugin provided in the other thread and using the code shown below.  You will have to now include category id's for it because I neglected to have it view all of them when that part of the array is empty.

Code: [Select]
$parameters = array(
'boards' => '1|2|3',
'board_color' => 'cadetblue',
'child_color' => 'gray',
'current_color' => 'turquoise',
'board_hover' => '#BC58C9',
'child_hover' => '#F9D26D',
'toggle_color' => '#4169e1',
'expand' => 'expand.gif',
'collapse' => 'collapse.gif',
'direction' => 'right',
'display' => 'full',
'accordian' => true,
'default' => false,
);

global $sourcedir;
require_once($sourcedir . '/PortalNavgoco.php');
sp_navgoco($parameters, 0, false);

Edit-> Added options for default toggle icons native to version 1.2.
Title: Re: SP Navigation Block.
Post by: Petter on March 28, 2014, 05:38:50 AM
Thanks  :)
Do you have a clue on how to fix the issue I mentioned? Making parentboards href="#" and just toggling the submenu?
Title: Re: SP Navigation Block.
Post by: Chen Zhen on April 01, 2014, 12:40:05 AM
Petter,

  Please update the plugin to version 1.3 whereas it may now behave as you requested.

Regards.
Title: Re: SP Navigation Block.
Post by: Petter on April 01, 2014, 01:40:17 AM
As I see, this update makes the categories toggle the submenu when clicking the link. I already fixed that by making href="#" in
Code: [Select]
<a style="color:', $customTextColors['bullet'], ';" href="', $scripturl, '?action=forum#c', $tree['node']['id'], '"><strong style="display:inline-block;color:', $customTextColors['board'], ';">', $tree['node']['name'], '</strong></a>';

The thing is that I want to do the same with the parent boards (not categories) since they are empty = containing only child boards, no subjects.
Making href="#" in
Code: [Select]
   <a style="color:', $customTextColors['child'], ';" href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a>';works but then the childboard links don´t work either...


I want it to work like this:

>Category  (clickling link just opens submenu)
  >Board 1  (Has children = clicking link just opens submenu)
        Childboard  (clicking link goes to board)
    Board 2 (Has no children = clicking link goes to board)


But I understand not everyone would like it like this, if they have subjects also in parentboards, as this board.

Title: Re: SP Navigation Block.
Post by: Chen Zhen on April 01, 2014, 07:21:14 PM
Petter,

The mod has been updated yet again although I did not increase the version number this time because their were few downloads since yesterday.

Here is the new code to use it manually:
Code: [Select]
$parameters = array(
'boards' => '1|2|3',
'board_color' => 'cadetblue',
'child_color' => 'gray',
'current_color' => 'turquoise',
'board_hover' => '#BC58C9',
'child_hover' => '#F9D26D',
'toggle_color' => '#4169e1',
'expand' => 'expand.gif',
'collapse' => 'collapse.gif',
'direction' => 'right',
'display' => 'full',
'accordian' => true,
'c_anchor' => false,
'b_anchor' => false,
'default' => false,
);

global $sourcedir;
require_once($sourcedir . '/PortalNavgoco.php');
sp_navgoco($parameters, 0, false);

  c_anchor and b_anchor now give the options to anchor the categories and/or boards. I agree with your request to anchor boards void of topics to the board index so I made that feature default within the file's code.

Regards.
Title: Re: SP Navigation Block.
Post by: Petter on April 10, 2014, 03:31:52 PM
Sorry, that did not work.


I have found another issue (have only tried in code above, not your mod): when logging out/in and some new boards become available or not, things get screwed up. Categories becomes childboards to boards.
I think it´s the cookie that needs to be reset, when logging in/out?
 
I saw there´s a destroy-command, is that for reseting the navgoco-cookie?
Title: Re: SP Navigation Block.
Post by: Chen Zhen on April 13, 2014, 10:53:37 PM
Petter,

  I had updated the plugin with your requested changes but not the block codes located in this thread.  Therefore if you want it to behave as you requested you will need to download and install the plugin but instead of using the prefab block provided, you should use the php code contained in my last post to use its function.
Title: Re: SP Navigation Block.
Post by: Petter on April 14, 2014, 01:41:28 AM
Yes, I did use the mod, of course. I found that regardless of if I tick "Anchor Selected Board", the parent board shows no arrow and links to /index.php?action=forum;#board_XX
instead of just toggling submenu.
Title: Re: SP Navigation Block.
Post by: Chen Zhen on April 15, 2014, 10:59:11 PM
Petter,

Since you are using the manually adjusted block code (as shown ~here~ (http://simpleportal.net/index.php?topic=1532.msg65723#msg65723)) as opposed to the prefab block, you will need to adjust the array for your specific settings. For example to have the boards and categories anchored you set those values to true as shown below:

(whole block code provided below)
Code: [Select]
$parameters = array(
'boards' => '1|2|3',
'board_color' => 'cadetblue',
'child_color' => 'gray',
'current_color' => 'turquoise',
'board_hover' => '#BC58C9',
'child_hover' => '#F9D26D',
'toggle_color' => '#4169e1',
'expand' => 'expand.gif',
'collapse' => 'collapse.gif',
'direction' => 'right',
'display' => 'full',
'accordian' => true,
'c_anchor' => true,
'b_anchor' => true,
'default' => false,
);

global $sourcedir;
require_once($sourcedir . '/PortalNavgoco.php');
sp_navgoco($parameters, 0, false);

.. do not forget to adjust other settings such as board id's, colors, etc.
Title: Re: SP Navigation Block.
Post by: Petter on April 16, 2014, 02:21:50 AM
No, I tried with the prefab block with correct settings in the SP admin. Does it work OK for you?
SimplePortal 2.3.8 © 2008-2024, SimplePortal