Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: Robert. on January 10, 2012, 01:10:25 PM

Title: BoardJump
Post by: Robert. on January 10, 2012, 01:10:25 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3296)

Boardjump mod v1.0
Description
With the boardjump mod you can jump to other boards quickly, like the jumpbox in the topic list. Unfortunately there is only 1 file edit required, because I didn't know where to put it elsewhere. I searched quite a long time, but I couldn't find it so I just decided to do a file edit instead. This mod requires SMF 2.0.x. This could work on other versions, but those are untested. Thanks to the SMF customization team for the rewrite. :)

Changelog
1.0
==============
- Initial release


Support
Support is available in the support topic, but I prefer answering support questions at my own site (http://getavax.co.cc) instead. You can use the English Help board for that.

Enjoy!
Title: Re: BoardJump
Post by: Robert. on January 10, 2012, 01:17:12 PM
Thanks for the approve :)
Title: Re: BoardJump
Post by: Bugo on January 10, 2012, 05:30:12 PM
QuoteUnfortunately there is only 1 file edit required, because I didn't know where to put it elsewhere.
You know there is a simple solution, with 2 hooks, 1 source file and 1 template file.

File hooks.php
<?php

if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
elseif(!
defined('SMF'))
die('<b>Error:</b> Cannot install - please verify that you put this file in the same place as SMF\'s index.php and SSI.php files.');

if ((
SMF == 'SSI') && !$user_info['is_admin'])
die('Admin privileges required.');

// Hooks
$hooks = array(
'integrate_pre_include' => '$sourcedir/Subs-BoardJump.php',
'integrate_load_theme' => 'boardjump_load_theme'
);

if (!empty(
$context['uninstalling']))
$call = 'remove_integration_function';
else
$call = 'add_integration_function';

foreach (
$hooks as $hook => $function)
$call($hook, $function);

if (
SMF == 'SSI')
echo 'Database changes are complete! Please wait...';

?>


File Subs-BoardJump.php
<?php

if (!defined('SMF'))
die('Hacking attempt...');

function
boardjump_load_theme()
{
global $context;

if (empty($context['current_action']))
{
loadTemplate('BoardJump');
$context['template_layers'][] = 'boardjump';
}
}

?>


File BoardJump.template.php (board list on top)
<?php

function template_boardjump_above()
{
global $context, $txt;

if (empty($context['categories'])) return;

echo '
<div class="windowbg" style="margin-top: 10px;">
<span class="topslice"><span></span></span>
<div class="content">
<form action="">
<label for="jump_above">'
, $txt['jump_to'], ':</label>
<select name="board" id="jump_above">'
;

foreach ($context['categories'] as $category)
{
echo '
<optgroup label="'
, $category['name'], '">';

foreach ($category['boards'] as $id_board => $board)
echo '
<option value="'
, $id_board, '">', $board['name'], '</option>';

echo '
</optgroup>'
;
}

echo '
</select>
<input type="submit" class="button_submit" value="'
, $txt['go'], '" style="text-transform: capitalize;" />
</form>
</div>
<span class="botslice"><span></span></span>
</div>
<br class="clear" />'
;
}

function
template_boardjump_below()
{
}

?>


Or ... file BoardJump.template.php (board list on bottom)
<?php

function template_boardjump_above()
{
}

function
template_boardjump_below()
{
global $context, $txt;

if (empty($context['categories'])) return;

echo '
<div class="windowbg" style="margin-top: 10px;">
<span class="topslice"><span></span></span>
<div class="content">
<form action="">
<label for="jump_below">'
, $txt['jump_to'], ':</label>
<select name="board" id="jump_below">'
;

foreach ($context['categories'] as $category)
{
echo '
<optgroup label="'
, $category['name'], '">';

foreach ($category['boards'] as $id_board => $board)
echo '
<option value="'
, $id_board, '">', $board['name'], '</option>';

echo '
</optgroup>'
;
}

echo '
</select>
<input type="submit" class="button_submit" value="'
, $txt['go'], '" style="text-transform: capitalize;" />
</form>
</div>
<span class="botslice"><span></span></span>
</div>
<br class="clear" />'
;
}

?>
Title: Re: BoardJump
Post by: Robert. on January 11, 2012, 06:17:05 AM
Thanks, considering that for the next version. :)
Title: Re: BoardJump
Post by: Ascot on May 15, 2012, 01:12:11 PM
Hi, can you show us some pictures or video on how it's working?
Were added Bugo's changes since his last response?
Title: Re: BoardJump
Post by: Robert. on May 15, 2012, 01:14:09 PM
Quote from: Ascot on May 15, 2012, 01:12:11 PM
Hi, can you show us some pictures or video on how it's working?
Sure, but I don't really have much time now. I'll try adding it as soon as possible, please send me a pm if I don't within a month. ;)

QuoteWere added Bugo's changes since his last response?
Nope, not yet, haven't edited this mod since the initial release. ;)
Title: Re: BoardJump
Post by: Ascot on September 13, 2012, 01:00:36 PM
Hi, can someone help  me to put this on a portal block?
I use simpleportal.
Title: Re: BoardJump
Post by: boo2 on October 04, 2012, 12:26:36 AM
Quote from: Bugo on January 10, 2012, 05:30:12 PM
QuoteUnfortunately there is only 1 file edit required, because I didn't know where to put it elsewhere.
You know there is a simple solution, with 2 hooks, 1 source file and 1 template file.
Dr. Deejays didn't work so I followed your post and hooks worked fine, put all the files where they are supposed to go but it didn't say what makes it show up? And where?

I too would like to put it in a block on simple portal where it would be most useful to me, but I have tried bits of the code in a block and can't make it work, because I really don't know what the code means.. lol

Doesn't look like Dr. Deejay is coming back. Could you explain how your code works? I have all installed by have no idea how to make it show up where I need it. I hope this thread isn't dead, would like to see this work.
Title: Re: BoardJump
Post by: Bugo on October 04, 2012, 03:42:40 AM
Quote from: boo2 on October 04, 2012, 12:26:36 AM
I too would like to put it in a block on simple portal where it would be most useful to me, but I have tried bits of the code in a block and can't make it work, because I really don't know what the code means.. lol
Well, just create a PHP block and paste this code:

global $context, $sourcedir, $modSettings, $txt;

if (empty($context['categories']))
{
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);
}

if (empty($context['categories'])) return;

echo '
<div class="windowbg" style="margin-top: 10px;">
<span class="topslice"><span></span></span>
<div class="content">
<form action="">
<label for="jump_below">', $txt['jump_to'], ':</label>
<select name="board" id="jump_below">';

foreach ($context['categories'] as $category)
{
echo '
<optgroup label="', $category['name'], '">';

foreach ($category['boards'] as $id_board => $board)
echo '
<option value="', $id_board, '">', $board['name'], '</option>';

echo '
</optgroup>';
}

echo '
</select>
<input type="submit" class="button_submit" value="', $txt['go'], '" style="text-transform: capitalize;" />
</form>
</div>
<span class="botslice"><span></span></span>
</div>
<br class="clear" />';
Title: Re: BoardJump
Post by: boo2 on October 04, 2012, 10:31:40 AM
Wow, that's great Bugo. After hours of messing with this thing it's a real treat to see it work.

Three things:

1. Could you make it go to the selected item with out the go button, like the regular jumpto does?

2. And I have Adk Topic button I found here: http://custom.simplemachines.org/mods/index.php?mod=3073

Could you make a 'separate' jumpto bit of code like this, that does something a bit different than this one, I'd find both useful.  Make another one, that when the item is selected, will take the person directly to the post new topic page for that item? Not sure I said that right, but that is what the adk topic button does. You click the icon next to a particular forum to start a new topic in that forum.

3. Question: would this same code you have for a block work where ever you wanted to put it, for instance would it work in the header, so it would be seen no matter where the person was? I'm sure that would be handy for those that would not want to switch back to the portal to get to it. Dr. Deejay's code placed in board index did nothing at all, but that could be because I have the whole entire info center removed for my purposes. Not sure. I am going to remove Dr. Deejays code, unless there's a reason to keep it, since I am using the code you posted originally.

Hope I am not pushing my luck and asking for too much.  :-\
Title: Re: BoardJump
Post by: Bugo on October 04, 2012, 10:40:04 AM
http://www.simplemachines.org/community/index.php?board=50.0
Title: Re: BoardJump
Post by: boo2 on October 04, 2012, 02:50:45 PM
Ok anyone who wants this and is stumped on how to make the block code jump directly to the board with out go button, or to make the jump go directly to make a new topic for that board, heres the answer. Now it works the way I wanted it originally.

http://simpleportal.net/index.php?topic=11912.new;topicseen#new

many thanks to Phantomm for working this out for me.
Title: Re: BoardJump
Post by: Robert. on January 04, 2013, 09:04:03 AM
This mod should work fine on 2.0.3. :)
Title: Re: BoardJump
Post by: Fredisland on December 31, 2020, 03:42:37 PM
Hello Robert.
Did you find the time to makethe hook version for your mod ? Because I love the fact options have all a style, they are not only in pure and boring text.
Thank you.
Fred, from France.