SimplePortal

Customization => Custom Coding => Topic started by: boo2 on October 04, 2012, 03:55:32 PM

Title: Jumpto in portal block
Post by: boo2 on October 04, 2012, 03:55:32 PM
Can anyone make this bit of code jump to selection with out having to use the go button? I asked the question where the individual made that piece of code but he just gave me a link to search for the answer and I haven't found anything that worked and I don't have a clue what I am doing with anything I find.

Here is the code:
Code: [Select]
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" />';
 

The original discussion was here:
http://www.simplemachines.org/community/index.php?topic=465107.new;topicseen#new

Hope I put this in the right place to get the answer. I'm not sure where I am supposed to put what..  :O
Title: Re: Jumpto in portal block
Post by: phantomm on October 04, 2012, 04:07:30 PM
Some parts stolen from Quick PM (http://simpleportal.net/index.php?topic=9406.0) block (by Dr. Deejay (http://simpleportal.net/index.php?action=profile;u=10073)) >:-D

Code: [Select]
global $context, $sourcedir, $modSettings, $txt, $scripturl;

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="#" method="post">
<label for="jump_below">', $txt['jump_to'], ':</label>
<select name="board" onchange="if (this.value) window.location.href=this.value">';

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

foreach ($category['boards'] as $id_board => $board)
echo '
<option value="', $scripturl, '?board=', $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: Jumpto in portal block
Post by: boo2 on October 04, 2012, 04:29:52 PM
You would not believe the things I tried the last couple of hours to get that thing to do that. Ugh Thank you so much.

Originally I set off to find a jump to box that would not just take a person to a particular board but would open a NEW TOPIC for that board. I got this for finding something that brought me to the selected board but not one that would take me to Open a new topic in it.

Is that easy to do? Or is that more complicated?

I have adk topic button which starts a new topic in the board shown in the category view, but I'd love a jump box where the member can chose the board they want to post a new topic in and it jumps to the new topic for that board.

My members and often I myself I don't have a lot of time to post so it would be most useful to get new topics posted quickly.

I did ask this question in the original topic too but got just a link to search, and my searches came up empty or just not related, and then I end up putting in bits of code that either throw an error at me or just don't work.

Title: Re: Jumpto in portal block
Post by: phantomm on October 04, 2012, 04:38:18 PM
I'm not sure.. you want something like this:
Code: [Select]
global $context, $sourcedir, $modSettings, $txt, $scripturl;

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="#" method="post">
<label for="jump_below">', $txt['jump_to'], ':</label>
<select name="board" onchange="if (this.value) window.location.href=this.value">';

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

foreach ($category['boards'] as $id_board => $board)
echo '
<option value="', $scripturl, '?action=post;board=', $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: Jumpto in portal block
Post by: boo2 on October 04, 2012, 05:17:00 PM
Yes yes yes yes yes. That puts it all together into exactly what I started out looking for. Big hug, Thank you thank you thank you.

Now just one last question, would this work no matter where I put it or is it just designed to work in a block? Not sure I need it elsewhere at the moment but just curious.
Title: Re: Jumpto in portal block
Post by: phantomm on October 04, 2012, 05:19:25 PM
I think that it should work outside block, but I would have to check it out later.
Title: Re: Jumpto in portal block
Post by: boo2 on October 04, 2012, 05:24:37 PM
I think that it should work outside block, but I would have to check it out later.

Ok because I followed Bugo's instructions on this page, http://www.simplemachines.org/community/index.php?topic=465107.new;topicseen#new

And up loaded the three files and ran hooks.php sucsessfully, but
there was no instruction how to make all that show on the forum. And I don't know if his block code for jumpto that I posted here was related to those instructions.

Thank you Phantomm for all your help. You made my day.
Title: Re: Jumpto in portal block
Post by: phantomm on October 05, 2012, 07:40:44 AM
You know, that this code from Bugo is exactly the same as this from Mod Site? Only difference is that Bugo's version doesn't edit any files, cause instead it's using hooks .

At least that's how I see it.
Title: Re: Jumpto in portal block
Post by: boo2 on October 05, 2012, 12:03:52 PM
Well I don't really understand about the hooks thing but always like it when mod doesn't change files. But I still don't know what his code does exactly, since it doesn't modify any files, how do you get it to show up? And where? You must have to put a piece of code somewhere to make it show up right?
Title: Re: Jumpto in portal block
Post by: phantomm on October 06, 2012, 09:41:36 AM
Now this is starting to be offtopic :P

Hooks install file is adding proper entries in SMF database, and this tells SMF what code should be loaded in selected places from PHP files.
I guess that better place to ask questions about hooks is simplemachines.org :)
Title: Re: Jumpto in portal block
Post by: boo2 on October 06, 2012, 01:03:07 PM
Now this is starting to be offtopic :P

Hooks install file is adding proper entries in SMF database, and this tells SMF what code should be loaded in selected places from PHP files.
I guess that better place to ask questions about hooks is simplemachines.org :)

No problem, Phantom, wasn't really asking about hooks, I wanted to know what makes his code actually show up somewhere in the forum. I followed all the instructions, but the one instruction to make it show up was not there. So the hooks being run and the files being placed where they should be, is pretty much useless if I don't know what makes it show up on the page.

It's just like this thread here, with out the piece that you supplied I could not have made the block thing work for me.

I don't know if his code even has anything to do with the block part, or it puts the jump somewhere else, but with out the piece that makes it go somewhere else, I don't know if anything I did in his instructions are even related other than it being jump related.
Title: Re: Jumpto in portal block
Post by: fapencio on May 07, 2014, 09:22:56 PM
Some parts stolen from Quick PM (http://simpleportal.net/index.php?topic=9406.0) block (by Dr. Deejay (http://simpleportal.net/index.php?action=profile;u=10073)) >:-D

Code: [Select]
global $context, $sourcedir, $modSettings, $txt, $scripturl;

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="#" method="post">
<label for="jump_below">', $txt['jump_to'], ':</label>
<select name="board" onchange="if (this.value) window.location.href=this.value">';

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

foreach ($category['boards'] as $id_board => $board)
echo '
<option value="', $scripturl, '?board=', $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" />';

phantomm your block is nice, I implemented this block in my forum, that was how it was:

(http://i56.servimg.com/u/f56/15/36/53/57/capt11.jpg)

works on all subforums, but does not work in the first subforum precisely where it appears in the picture, it is the only subforum I need to click the button "Go" , when I click the button "Go"  nothing happens , I would like to help me correct that "bug", and please make the block is as it is on this site: medicomoderno.org

(http://i56.servimg.com/u/f56/15/36/53/57/capt210.jpg)

ie, instead of display the first sub-forum, show the title "choose category" and remove the "Go" button please

Title: Re: Jumpto in portal block
Post by: fapencio on May 08, 2014, 09:58:05 PM
help please
Title: Re: Jumpto in portal block
Post by: phantomm on May 10, 2014, 01:30:59 PM
Something like this?
Code: [Select]
global $context, $sourcedir, $modSettings, $txt, $scripturl;

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="#" method="post">
<select name="board" onchange="if (this.value) window.location.href=this.value">
<option value="0" selected="selected" disabled="disabled">Select board</option>';

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

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

echo '
</optgroup>';
}

echo '
</select>
</form>
</div>
<span class="botslice"><span></span></span>
</div>
<br class="clear" />';
Title: Re: Jumpto in portal block
Post by: fapencio on May 10, 2014, 01:51:15 PM
Something like this?

exactly, now work perfect,  :thumbsup:

the help you provide is invaluable, without you we do not know of code would know what not to do

thanks a lot phantomm  :thumbsup: :applause:
Title: Re: Jumpto in portal block
Post by: phantomm on May 10, 2014, 04:39:53 PM
You're Welcome :)
SimplePortal 2.3.8 © 2008-2024, SimplePortal