SimplePortal

Customization => Custom Coding => Topic started by: xKroniK13x on May 20, 2014, 07:37:51 PM

Title: Manually Adding Shoutbox
Post by: xKroniK13x on May 20, 2014, 07:37:51 PM
Hello guys, it's been a while since I've posted here. I have a quick question. I am currently implementing a mobile solution to my website, and am having some trouble. I am trying to add the shoutbox to just the BoardIndex template (so that regardless of the shoutbox settings, it is ONLY shown on the board index page). I cannot, for the life of me, figure out how to manually add the shoutbox to the page. I looked through all of the installation scripts for Simple Portal, and I've also attempted to pull some of the php from the Shoutbox template files... to no avail.

Anyone have any guidance here? Thank for the help!
Title: Re: Manually Adding Shoutbox
Post by: AngelinaBelle on May 20, 2014, 08:34:01 PM
You will be able to do this using a block with custom display options. 
The ~action|forum should do the trick.
Make sure you have enabled SimplePortal blocks in the forum.
Title: Re: Manually Adding Shoutbox
Post by: xKroniK13x on May 21, 2014, 08:01:11 AM
You will be able to do this using a block with custom display options. 
The ~action|forum should do the trick.
Make sure you have enabled SimplePortal blocks in the forum.

It appears on every theme BUT the mobile theme. I believe it's because the SimplePortal install script failed on the mobile theme. I can't seem to get it to do any modifications on the theme.
Title: Re: Manually Adding Shoutbox
Post by: AngelinaBelle on May 22, 2014, 09:46:02 AM
SimplePortal only makes 2 changes to themes, and these would NOT prevent any simpleportal blocks from showing.
So this is not the main cause of your problem.

I imagine that the main cause of your problem is that SimplePortal will disable itself if the constant WIRELESS is defined
This is because, in SMF, WIRELESS is only defined in the case of WAP, WAP2, or IMODE -- all of which indicate old phone browsers that can't handle a lot of HTML and CSS (and were built to operate on old, extremely low bandwidth cell data networks, back in the days when cell phones were designed to be used mainly for audio communications).

So I am going to guess again that your mobile theme comes with a mod in index.php that detects common mobile browsers, sets WIRELESS and WIRELESS_PROTOCOL, and uses the mobile theme.
This is just a guess; I am not familiar with any mobile mods or themes.

If you share with us the section of index.php which follows loadSession(), we may be able to help you make some changes that will allow SimplePortal to work with this mod's redefinition of what WIRELESS means.

Title: Re: Manually Adding Shoutbox
Post by: xKroniK13x on May 22, 2014, 02:03:12 PM
This is the part of index.php after the loadSession(). I don't see any changes... or at least none that would change themes, etc.

Code: [Select]
// Determine if this is using WAP, WAP2, or imode.  Technically, we should check that wap comes before application/xhtml or text/html, but this doesn't work in practice as much as it should.
if (isset($_REQUEST['wap']) || isset($_REQUEST['wap2']) || isset($_REQUEST['imode']))
unset($_SESSION['nowap']);
elseif (isset($_REQUEST['nowap']))
$_SESSION['nowap'] = true;
elseif (!isset($_SESSION['nowap']))
{
if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/vnd.wap.xhtml+xml') !== false)
$_REQUEST['wap2'] = 1;
elseif (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'text/vnd.wap.wml') !== false)
{
if (strpos($_SERVER['HTTP_USER_AGENT'], 'DoCoMo/') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'portalmmm/') !== false)
$_REQUEST['imode'] = 1;
else
$_REQUEST['wap'] = 1;
}
}

if (!defined('WIRELESS'))
define('WIRELESS', isset($_REQUEST['wap']) || isset($_REQUEST['wap2']) || isset($_REQUEST['imode']));

// Some settings and headers are different for wireless protocols.
if (WIRELESS)
{
define('WIRELESS_PROTOCOL', isset($_REQUEST['wap']) ? 'wap' : (isset($_REQUEST['wap2']) ? 'wap2' : (isset($_REQUEST['imode']) ? 'imode' : '')));

// Some cellphones can't handle output compression...
$modSettings['enableCompressedOutput'] = '0';
// !!! Do we want these hard coded?
$modSettings['defaultMaxMessages'] = 5;
$modSettings['defaultMaxTopics'] = 9;

// Wireless protocol header.
if (WIRELESS_PROTOCOL == 'wap')
header('Content-Type: text/vnd.wap.wml');
}

// Restore post data if we are revalidating OpenID.
if (isset($_GET['openid_restore_post']) && !empty($_SESSION['openid']['saved_data'][$_GET['openid_restore_post']]['post']) && empty($_POST))
{
$_POST = $_SESSION['openid']['saved_data'][$_GET['openid_restore_post']]['post'];
unset($_SESSION['openid']['saved_data'][$_GET['openid_restore_post']]);
}

I am using a modified version of this theme (http://custom.simplemachines.org/themes/index.php?lemma=2089), and am using this mod (http://custom.simplemachines.org/mods/index.php?mod=3349) for detection.

Thanks for the help!
Title: Re: Manually Adding Shoutbox
Post by: AngelinaBelle on May 22, 2014, 02:29:19 PM
You can go through the manual installation instructions for the mod yourself.
http://custom.simplemachines.org/mods/index.php?action=parse;mod=3349;attach=201257;smf_version=2.0.7
I suspect, if it is anywhere, that Subs-MobileDetect.php is the culprit.

I have not scoured any of this code myself.

The author of that mod, emanuele seems like a great guy to me.He can be very helpful.  Explain the problem, and ask if the mod does anything to set WIRELESS for other clients than the wap, wap2, and imode clients that out-of-the-box SMF does.  He can point you at the correct portion of the code, and coming up with some way to make the two mods and the theme compatable will be much easier after that, I think.
Title: Re: Manually Adding Shoutbox
Post by: xKroniK13x on May 22, 2014, 02:36:01 PM
You can go through the manual installation instructions for the mod yourself.
http://custom.simplemachines.org/mods/index.php?action=parse;mod=3349;attach=201257;smf_version=2.0.7
I suspect, if it is anywhere, that Subs-MobileDetect.php is the culprit.

I have not scoured any of this code myself.

The author of that mod, emanuele seems like a great guy to me.He can be very helpful.  Explain the problem, and ask if the mod does anything to set WIRELESS for other clients than the wap, wap2, and imode clients that out-of-the-box SMF does.  He can point you at the correct portion of the code, and coming up with some way to make the two mods and the theme compatable will be much easier after that, I think.

I'll take a look at the Subs-MobileDetect script and see what I can come up with. I'll report back with my findings, whether on my own, or with the help of the developer.  8)
Title: Re: Manually Adding Shoutbox
Post by: xKroniK13x on May 22, 2014, 07:55:47 PM
So I've been thinking about it and doing some trial and error... I disabled the WIRELESS testing by a few lines of code in the index.php placed after the lines of codes above...

Code: [Select]
if (isset($_REQUEST['wap']) || isset($_REQUEST['wap2']) || isset($_REQUEST['imode'])) {
unset($_REQUEST['wap']);
unset($_REQUEST['wap2']);
unset($_REQUEST['imode']);
}

And then I was thinking about it... it is indeed an issue with the theme. If I disable the auto detection mod, and just set the forum default theme to the mobile theme, it still will not display the shoutbox (or any block, for that matter). Maybe the easiest thing would be to make a blank page with the shoutbox, and iFrame it into the theme.
Title: Re: Manually Adding Shoutbox
Post by: AngelinaBelle on May 23, 2014, 03:04:02 PM
You would also have to prevent WIRELESS from being defined in index.php and/or portal standalone.php. 
Can you use the mobile theme on your desktop by Calling it directly?
What happens if you uninstall the mod?

Have you asked Emanuel about the issue?
If you see how SimplePortal works, it works by calling an additional theme layer, which can be layered into any theme -- unless it is disabled. 
Title: Re: Manually Adding Shoutbox
Post by: xKroniK13x on May 23, 2014, 09:46:49 PM
You would also have to prevent WIRELESS from being defined in index.php and/or portal standalone.php. 
Can you use the mobile theme on your desktop by Calling it directly?
What happens if you uninstall the mod?

Have you asked Emanuel about the issue?
If you see how SimplePortal works, it works by calling an additional theme layer, which can be layered into any theme -- unless it is disabled.

I have not spoken to Emanuel, simply because I over-rode the setting of WIRELESS with the code I posted above. I did get my SimplePortal integration working, thanks to an SMF forum member named filmstarr, who recently started modifying the theme again to update it to meet new mobile standards. It is a little rough at the moment, but completely functional.

Thanks a ton for the help... and for future people that may run into the same problem, this is (https://github.com/filmstarr/iOS.MF/tree/SimplePortal) a link to the GitHub for the new theme, that is working with SP right now.
Title: Re: Manually Adding Shoutbox
Post by: AngelinaBelle on May 27, 2014, 03:01:35 PM
I'm glad that theme changes helped you get this working.
SimplePortal 2.3.8 © 2008-2024, SimplePortal