I have a partially built weather mod for the US that uses a custom profile field for zip code for the location. It's a badly edited version of the current mod in development here, combined with the old weather mod from B3P version 1. I can't upload the files here, but if somebody wants to help me figure out how to fix it, I can upload the code to my next post.
So far, I have a mod that actually works. However, I can't get add the module without getting an error, I can't get into the ACP settings, and I can't delete it without removing it from the database manually. It DOES get added and it DOES work.
Just need a little help finishing it up. Anybody interested?
Weather mod for US using Accuweather
Forum rules
This forum is not for support requests.
Only post Modifications for Board3 Portal 2.0.x in this forum.
This forum is not for support requests.
Only post Modifications for Board3 Portal 2.0.x in this forum.
Re: Weather mod for US using Accuweather
Okay, well... Without further ado, let me just post what I have and I'll see if anybody can see the mistakes - and there are many! First, you create a custom profile field for zip code (field ID = zip_code). I limited it to five characters, as I think that's what Accuweather uses in the US and it has to match.
Next, the language file (english only at the moment): root/language/en/mods/portal/portal_weather_module.php
This is modified from the other module version, which I don't understand and since we don't use country codes, etc., I stripped some of it out.
Then, the portal_weather module, in root/portal/modules, which is taken from the new european module with the old weather.php code inserted:
I think this needs to be added to the end before the last "}":
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
global $db;
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
Am I right?
In styles/template/prosilver/weather_center.html, I have:
I haven't made a side block yet, but Accuweather offers a small version, so it should be simple.
Anyway, with a (small) database repair, I did manage to install this block, though I still get errors when I try to edit the block, and I'm hoping somebody can help me finish this thing up. If I go to try to modify the settings in the ACP, I get this error:
Thanks!
Next, the language file (english only at the moment): root/language/en/mods/portal/portal_weather_module.php
Code: Select all
<?php
/**
*
* @package Board3 Portal v2 - AccuWeather Weather Module
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
$lang = array_merge($lang, array(
'PORTAL_WEATHER' => 'Regional Weather',
// ACP
'ACP_PORTAL_WEATHER_SETTINGS' => 'Weather settings',
));
Then, the portal_weather module, in root/portal/modules, which is taken from the new european module with the old weather.php code inserted:
Code: Select all
<?php
/**
*
* @package Board3 Portal v2 - AccuWeather
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Weather
*/
class portal_weather_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 31;
/**
* Default modulename
*/
public $name = 'PORTAL_WEATHER';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_weather.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_weather_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = '';
/**
* hide module name in ACP configuration page
*/
public $hide_name = false;
public function get_template_center($module_id)
{
global $config, $template, $user, $db;
$sql = "SELECT pf_zip_code
FROM " . PROFILE_FIELDS_DATA_TABLE . "
WHERE user_id = " . $user->data['user_id'];
$result = $db->sql_query_limit($sql, 1);
$zip_code = $db->sql_fetchfield('pf_zip_code');
$db-> sql_freeresult($result);
$template->assign_vars(array(
'WEATHER_ZIP' => (!empty($zip_code)) ? $zip_code : '80201', // Change 20099 to the wished default ZIP code
));
return 'weather_center.html';
}
public function get_template_side($module_id)
{
global $config, $template, $user, $db;
$sql = "SELECT pf_zip_code
FROM " . PROFILE_FIELDS_DATA_TABLE . "
WHERE user_id = " . $user->data['user_id'];
$result = $db->sql_query_limit($sql, 1);
$zip_code = $db->sql_fetchfield('pf_zip_code');
$db-> sql_freeresult($result);
$template->assign_vars(array(
'WEATHER_ZIP' => (!empty($zip_code)) ? $zip_code : '80201', // Change 20099 to the wished default ZIP code
));
return 'weather_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'PORTAL_WEATHER',
);
}
}
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
global $db;
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
Am I right?
In styles/template/prosilver/weather_center.html, I have:
Code: Select all
{$C_BLOCK_H_L}{$TITLE}{$C_BLOCK_H_R}
<div class="postbody" style="width: 100%">
<div class="post bg2" style="margin-bottom: 0px">
<div class="inner"><span class="portal-corners-top-inner"></span>
<div style="text-align: center;">
<!-- Weather Start -->
<div style='width: 728px; height: 90px; background-image: url( http://vortex.accuweather.com/adcbin/netweather_v2/backgrounds/hurricane_728x90_bg.jpg ); background-repeat: no-repeat; background-color: #0F243A;' ><div style='height: 74px;' ><script src='http://netweather.accuweather.com/adcbin/netweather_v2/netweatherV2.asp?partner=netweather&tStyle=dark2&logo=1&zipcode={WEATHER_ZIP}&lang=eng&size=11&theme=hurricane&metric=0&target=_self'></script></div><div style='text-align: center; font-family: arial, helvetica, verdana, sans-serif; font-size: 11px; line-height: 16px; color: #FDEA11;' ><img style='float: right; padding-right: 5px;' src='http://vortex.accuweather.com/adc2004/common/images/misc/netweather_v2/adcwhite.png' /></div></div>
<!-- Weather End -->
</div>
<br />
<span class="portal-corners-bottom-inner"></span></div></div></div>
{$C_BLOCK_F_L}{$C_BLOCK_F_R}
Anyway, with a (small) database repair, I did manage to install this block, though I still get errors when I try to edit the block, and I'm hoping somebody can help me finish this thing up. If I go to try to modify the settings in the ACP, I get this error:
I know I'm asking a LOT, but if somebody can help very briefly (I hope), we'll have a US weather block for B3P v.2.[phpBB Debug] PHP Warning: in file [ROOT]/adm/index.php on line 389: Invalid argument supplied for foreach()
[phpBB Debug] PHP Warning: in file [ROOT]/includes/acp/acp_portal.php on line 205: Invalid argument supplied for foreach()
[phpBB Debug] PHP Warning: in file [ROOT]/includes/acp/acp_portal.php on line 319: Invalid argument supplied for foreach()
Thanks!