SimplePortal

Customization => Blocks and Modifications => Mod Requests => Topic started by: Divecall on March 07, 2012, 07:03:40 PM

Title: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Divecall on March 07, 2012, 07:03:40 PM
Hello!

It is possible to add a link or an icon (next to the existing one, like history, smileys, design...) and when a member click on that icon, the shoutbox (with all the last shouts from the history) open in a new window or in a new page but full functionally ?




Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Chen Zhen on March 07, 2012, 09:57:35 PM
Divecall,

Yes this is possible by creating a page, adding one simple edit to a SP file & uploading one image file via FTP.

file: Themes / default / PortalShoutbox.template.php

Find:
Code: [Select]
if ($context['can_shout'])
echo ' <a href="#smiley" onclick="sp_collapse_object(\'sb_smiley_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('smiley'), '</a> <a href="#style" onclick="sp_collapse_object(\'sb_style_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('style'), '</a>';

Replace with:
Code: [Select]
if ($context['can_shout'])
echo ' <a href="#smiley" onclick="sp_collapse_object(\'sb_smiley_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('smiley'), '</a> <a href="#style" onclick="sp_collapse_object(\'sb_style_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('style'), '</a>';

if ((!empty($_REQUEST['page']) ? $_REQUEST['page'] : false) != 'shoutbox1')
echo '&nbsp;&nbsp;<a href="javascript:void(0);" onclick="return fullPage()" title="Full Page">',sp_embed_image('full_page'),'</a>
<script type="text/javascript">function fullPage() {window.open("'.$scripturl.'?page=shoutbox1", "Shoutbox");return false;}</script>';
else
echo '&nbsp;&nbsp;<a href="javascript:void(0);" onclick="window.close()" title="Exit Full Page">',sp_embed_image('full_page'),'</a>';



Now create a portal page on your forum: Admin -> Pages -> Add Page


Place this in the Body:
Code: [Select]
global $sourcedir;

@require_once($sourcedir . '/PortalBlocks.php');
$parameters['shoutbox'] = 1;
$id = 41;
$return_parameters = false;
sp_shoutbox($parameters, $id, $return_parameters);

Now upload the attached image file to: Themes / default / images / sp



Now when you display your shoutbox, an extra image/link will appear that will open a new window with your page that shows the opted shoutbox. Clicking the same image/link in the new page will then close it.



Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Divecall on March 08, 2012, 01:47:27 PM
WOW...fast answer!

Thank you at first, i will test this at weekend.

If i have some problems, i will write this here.

 :applause:
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Costa on June 28, 2012, 10:25:15 AM
Sorry to bump this thread. But is possible in the new page set the height of the shoutbox bigger?
At least the double size.

Thanks in advance.
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Chen Zhen on June 28, 2012, 07:34:54 PM
Costa,

You can enter specifics for the window being opened within the javascript command.

ie.
Code: [Select]
if ($context['can_shout'])
echo ' <a href="#smiley" onclick="sp_collapse_object(\'sb_smiley_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('smiley'), '</a> <a href="#style" onclick="sp_collapse_object(\'sb_style_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('style'), '</a>';

if ((!empty($_REQUEST['page']) ? $_REQUEST['page'] : false) != 'shoutbox1')
echo '&nbsp;&nbsp;<a href="javascript:void(0);" onclick="return fullPage()" title="Full Page">',sp_embed_image('full_page'),'</a>
<script type="text/javascript">function fullPage() {window.open("'.$scripturl.'?page=shoutbox1", "Shoutbox", "location=1,status=1,scrollbars=1, width=250,height=400");return false;}</script>';
else
echo '&nbsp;&nbsp;<a href="javascript:void(0);" onclick="window.close()" title="Exit Full Page">',sp_embed_image('full_page'),'</a>';

Just edit this part from above:
Code: [Select]
"location=1,status=1,scrollbars=1, width=250,height=400"

.. with the specifics for the page being opened.

Here are some examples of the needed syntax: Click Here (http://www.javascript-coder.com/window-popup/javascript-window-open.phtml)
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Costa on July 01, 2012, 12:27:03 AM
Thanks mate. :)
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Costa on July 03, 2012, 11:38:23 AM
Srry for the bump, but didn't work. I have thechat in a separate page, but with the same size.

Here is my code.

Code: [Select]
if ($context['can_shout'])
echo ' <a href="#smiley" onclick="sp_collapse_object(\'sb_smiley_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('smiley'), '</a> <a href="#style" onclick="sp_collapse_object(\'sb_style_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('style'), '</a>';

if ((!empty($_REQUEST['page']) ? $_REQUEST['page'] : false) != 'shoutbox1')
echo '&nbsp;&nbsp;<a href="javascript:void(0);" onclick="return fullPage()" title="Full Page">',sp_embed_image('full_page'),'</a>
<script type="text/javascript">function fullPage() {window.open("'.$scripturl.'?page=chat", "Chat", "location=1,status=1,scrollbars=1,width=250,height=500");return false;}</script>';
else
echo '&nbsp;&nbsp;<a href="javascript:void(0);" onclick="window.close()" title="Exit Full Page">',sp_embed_image('full_page'),'</a>';
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: 420connect on March 08, 2015, 12:50:40 PM
Sorry for bumping an oldie!

I've just added the code in and it's working as it should, however I'm also looking to add the changes the previous poster was looking for.

How can I set a new shoutbox height for the 'full page' one?, not a new window height like the above code suggests.

Many thanks
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: ♦ Ninja ZX-10RR ♦ on March 08, 2015, 12:55:08 PM
Don't get what you mean >_<
By the way an URL to that page might help, make sure it's visible to guest, too. I might have a go with .css :P
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: 420connect on March 08, 2015, 12:59:16 PM
My shoutbox is members only but details are below if you would :)

a: smftest
pw: smftest
http://www.420connect.info
(you should see the chat or direct new page:
http://www.420connect.info/forum/index.php?page=shoutbox1 )

I'm looking to have the actual shoutbox larger in height.
( so you can see more than the current amount of messages, on screen at once.)


The above suggestions to change the height were to do with the window of the pop up,
not the actual shoutbox it's self :(


Many thanks and I hope this makes sense! :)
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: ♦ Ninja ZX-10RR ♦ on March 08, 2015, 02:01:47 PM
Since it's the same shoutbox I can't find a way to do it... Due to the fact that the page doesn't add a div_id :/
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: 420connect on March 08, 2015, 02:15:02 PM
Yup, I've tried a few things to use the same shoutbox, with a new height but its proving much harder than expected :(
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: ♦ Ninja ZX-10RR ♦ on March 08, 2015, 02:26:19 PM
Yes because the height affects BOTH places and there is no way to do it via .css because the page you added doesn't add a new div class :( So I can't use a custom css selector to increase the relative height :( Thought it was easier myself, indeed.
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Chen Zhen on March 08, 2015, 06:01:33 PM
420connect,

The shoutbox container has a specific id pertaining to the shoutbox number.
You can dynamically change the container height on your shoutbox page.

Use this for your PHP page code:
Code: [Select]
$height = '500px';

global $sourcedir;
@require_once($sourcedir . '/PortalBlocks.php');
$parameters['shoutbox'] = 1;
$id = 41;
$return_parameters = false;
sp_shoutbox($parameters, $id, $return_parameters);
echo '<script type="text/javascript">
document.getElementById("shouts_', $parameters['shoutbox'], '").style.height="', $height, '";
</script>';

.. change the $height variable at the onset of the provided code to what is desired.

Regards.
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: 420connect on March 09, 2015, 12:13:15 PM
(http://i302.photobucket.com/albums/nn103/i_am_deeply_in_love/smileys/smiley-blowing-kisses.gif)

Thank you very much Chen! :)
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: ♦ Ninja ZX-10RR ♦ on March 09, 2015, 01:24:54 PM
Chen Zhen... You are awesome, I will use this as well. Thank you very much! :D
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Grammy on May 21, 2016, 04:05:15 PM
The file edited fine, the image shows up and I was pretty excited, at first...

But while trying the instructions for adding a new page on THIS POST (http://simpleportal.net/index.php?topic=10812.msg55702#msg55702), I keep failing dismally.  I'm new to SimplePortal and, apparently, cannot grasp something as simple as adding a new page.  I can do it as long as I don't put anything at all in the body.  Otherwise, I get "Database error in block code. Please check the code."  Am I supposed to wrap this bit of code

Code: [Select]
global $sourcedir;

@require_once($sourcedir . '/PortalBlocks.php');
$parameters['shoutbox'] = 1;
$id = 41;
$return_parameters = false;
sp_shoutbox($parameters, $id, $return_parameters);

in some sort of HTML tags when adding it to the "Body" field?  I've never successfully added a page before, so I already admit that whatever's going on is because I have no clue what I'm doing.   :(
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: ♦ Ninja ZX-10RR ♦ on May 21, 2016, 06:20:30 PM
Hi and welcome to SimplePortal.

I'm honestly not sure where you can be failing, the guide is literally step-by-step and I don't know myself how to explain it better than that, if you tell us exactly what you've done maybe we can get an idea...

Regards
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Grammy on May 21, 2016, 10:01:35 PM
Thanks so much for your reply. 

I'm attaching a screenshot of the set up, just before I try to click to add the page.  If I click Preview first, I can see the way the page will look.  But if I then click Add Page, I get "Database error in block code. Please check the code."

I have a dedicated server, Linux, and I'm not seeing any errors in the server logs.  I'm pretty much just stumped. 

SMF 2.0.11 (default), SP 2.3.6

(Well, well, well... is the name of the shoutbox block, in case it seems the shoutbox is missing from the blocks.)



EDIT:  I hope it's not too late to add this, but I just found out I can add the page if I don't put anything at all into the Body field.  So it has to do with what I'm adding, apparently.   :0
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Grammy on May 23, 2016, 12:07:47 PM
I was wondering if I should start a new thread and link to this one?   :(
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: emanuele on May 23, 2016, 12:44:38 PM
Try disabling php validation (in SP settings).
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Grammy on May 23, 2016, 12:51:05 PM
Try disabling php validation (in SP settings).


You're a Rock Star, thanks!  Sorted!   :nervous-happy:
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Chen Zhen on May 23, 2016, 04:10:38 PM
Advanced options
For the custom display options of the actual block you might want to add this in the field:
Code: [Select]
-~page|shoutbox1
(also ensure to adjust specific actions and/or boards when using the custom field)
 ... otherwise the shoutbox will appear twice when the "page" is displayed.
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: Grammy on May 23, 2016, 05:24:35 PM
Advanced options
For the custom display options of the actual block you might want to add this in the field:
Code: [Select]
-~page|shoutbox1
(also ensure to adjust specific actions and/or boards when using the custom field)
 ... otherwise the shoutbox will appear twice when the "page" is displayed.

Yikes!  Thanks, fixed!   :nervous-happy:
Title: Re: Shoutbox open in a new window or new page (Full Chat icon)
Post by: DragoN_PT on March 03, 2017, 12:40:36 PM
Sorry for the (1year old thread) bump but i need a little help with this. I follow everything and everything is running as intended but i wish to make the button to open the shoutbox in a new POPUP instead of a full page. I think i just need to edit the following bit of code:

Code: [Select]
if ((!empty($_REQUEST['page']) ? $_REQUEST['page'] : false) != 'shoutbox1')
echo '&nbsp;&nbsp;<a href="javascript:void(0);" onclick="return fullPage()" title="Full Page">',sp_embed_image('popup'),'</a>
<script type="text/javascript">function fullPage() {window.open("'.$scripturl.'?page=shoutbox1", "Shoutbox");return false;}</script>';
else
echo '&nbsp;&nbsp;<a href="javascript:void(0);" onclick="window.close()" title="Exit Full Page">',sp_embed_image('popup'),'</a>';

to reflect that but after so many failed tries I decided to ask for help here. I like the way it is now i just want to change the onclick= function to open a new popup and (if possible) after the popup is open the button would bring people back to the site (instead of "Exit full page").

Another thing i noticed is that using the Simpleportal "Add Page" to build the shoutbox page it will show all the theme styles (header and ect) and I just want to show the shoutbox contents. For that I've tried to make a block instead of a page and it worked. On the block it only shows the shoutbox without any theme related styles, thing is I dunno how to open the block in a popup like I do with a page (i dunno the block hyperlink if there is one...).

Maybe some of you guys can take a couple of minutes to help me out.

SimplePortal 2.3.8 © 2008-2024, SimplePortal