Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases

Reply
 
Thread Tools
vB Weather: Give your members current weather and forecasts! Details »»
vB Weather: Give your members current weather and forecasts!
Version: 1.00, by JJR512 JJR512 is offline
Developer Last Online: Jun 2006 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 02-25-2002 Last Update: Never Installs: 25
 
No support by the author.

After seeing a weather feature at the vbPortal website, and finding out that I couldn't get it for free, I determined to create it for myself, and give it away to everyone for FREE.

So here it is. It's based in part upon the original MyWeather add-on module for PHP-Nuke, which as I understand was also the basis for the add-on module for vbPortal. Anyway, I basically used the part of the PHP-Nuke module that gets the raw data and parses it into a usable format, although I reworked it some and corrected a few bugs. I wrote on my own the rest of the code which handles and displays the data, along with letting the user select his/her location (to localize the weather), number formats (like ?F or C, winds in mph or kmph, etc.), and various other little bits.

I've done as much testing on it as I can on my own, and have had it running on my own production forums for about a day now. Several people have commented that they really love the feature, that it's almost getting to the point where they don't have to go anywhere else on the Internet. I haven't heard of any complaints or problems yet, though, so I'm reasonably certain it's fit for a full release.

You can demo the hack on my message board: JJR512.com. The first part you should look at is the box that appears in the column of boxes on the left side of the home page. This box displays basic current weather info. There are two links in that box, one to see the forecast, and the other to change settings. I forget if you need to be logged in to see the forecast--it may just show you a forecast for the default location, which is Central Park, New York City, NY, USA--but you definitely need to be logged in to change settings. For the purpose of seeing this hack in action, you can login as Test User using the password testuser. Feel free to change the settings and save them, do whatever.

Installing this hack is in some ways easy, in other ways not so easy. There will only be one file modification. However, there are no specific instructions as to which file to edit or how to edit it. If you want the small weather box to show up on your forums home page, you need to edit the associated file (index.php). If you want it to show up somewhere else, then you need to edit whatever file generates the page where you want it. There is a text file in the ZIP that contains all the code, and only the code, that you need to insert into whatever file. If you prefer, you can turn that text file into a .php file (by adding <?php at the beginning and ?> at the end and renaming it to .php) and simply including it in whatever file you need it in.

You will also most likely need to edit the template that makes the weather box. It's formatted to basically make a box as it appears on my site, which is in the middle of some other boxes in a column. If you want to reformat it to appear as a long thing across the top of the page, like the various stuff at the top of the forums home page here at vbulletin.org, that's up to you. You edit the templates to match your own site.

BTW, I would appreciate it if someone better at PHP coding than myself would take a look over this and tell me if I've done everything right or not. I believe the code works and does what I want it to do, but it seems like it might be a little more complex than it needs to or should be. I guess I'm just wondering if there may have been a more efficient way to do some of the things I did. If you have any tips or advice for me, or even want to rewrite the code to show me, I'd really appreciate it.

OK, so without further ado, here's the hack in the attachment. Whatever problems you have, please post them here, and I'll try to help as best I can, but make no guarantees that I can help at all. Please remember that I write my hacks for my own site first and foremost, so they do what I need them to do, not what I think somebody else might want. I choose to release them here in case anybody else can benefit from them, but you may need some part of it to work slightly differently. If I know how to do it I will try to tell you how to do it, but I won't update the hack with every little feature variation that people ask for. In general, I only update my hacks to fix bugs and to add new features that I want or need for my site.

// Change Log]
03b: Includes necessary database change instructions.
03a: Forgot to update 03 ZIP with new templates; fixed.
03: Changed code for new icon system, added code for forecasted weather type (new part of raw data)
02: Adjusted code for new format of weather forecast raw data
01b: Fixed two missing lines from weather_include.txt
01a: Added missing template; updated instructions regarding missing template; fixed $templatesused variable in weather.php; added text file explaining how to add more cities; updated instructions regarding where to get the icons used for this hack
01: Original release

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 02-26-2002, 09:50 PM
JJR512's Avatar
JJR512 JJR512 is offline
 
Join Date: Oct 2001
Location: Glen Burnie, MD, USA
Posts: 710
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

qwaz, I guess I don't know how to help you to get it to show up on every page. Maybe someone else knows the secret.

As far as only displaying one city, first set the settings for yourself to the city you want, then find this part in weather.php:
PHP Code:
if (!isset($action) or $action=="getdata") {
  
$userdata $DB_site->query_first("SELECT * FROM weather_userdata WHERE userid=$bbuserinfo[userid]"); 
Change $bbuserinfo[userid] to your own userid number. You can probably take out all the code from the Modify and Update Settings sections.
Reply With Quote
  #23  
Old 02-27-2002, 05:14 PM
HiroshiNanami HiroshiNanami is offline
 
Join Date: Feb 2002
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great hack JJR. I just got a question. Would putting weather_include in phpinclude be such a good idea since you would be accessing the db on each and every page load? Wouldn't it slow down processing and hog resources in a large forum?

Has anyone tried using phpinclude to display the weather in every page in a busy forum?
Reply With Quote
  #24  
Old 02-27-2002, 06:46 PM
JJR512's Avatar
JJR512 JJR512 is offline
 
Join Date: Oct 2001
Location: Glen Burnie, MD, USA
Posts: 710
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know what kind of impact it would have. Obviously, the database is being accessed on every page load anyway. If someone wanted the weather data on every page, there would need to be additional related calls to the database for every page, also, regardless of how or where the code was put. If it's too much of an impact, then that board won't be able to have it on every page.

Personally, I do not believe it's necessary or important to have the weather on every page. Even if you had a standarized set of boxes of stuff that appear in a column on the side of the forums, I think there is certain stuff that doesn't need to be there on every single forums page, maybe just the home page.
Reply With Quote
  #25  
Old 02-27-2002, 09:32 PM
Mutt's Avatar
Mutt Mutt is offline
 
Join Date: Nov 2001
Posts: 331
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The directions were great and it was a very easy install. thanks for making the templates and the tables individual files. it make importing them very easy.

I plan on customizing it but for now I just wanted to get it working.

have it running here
http://www.ccdv.com/forum/homeindex.php

JJR512 - the diections forgot to mention the redirect template. it's in the zip, but it wasn't in the template section of the directions. just wanted to let you know so you could update the zip. Once again, great job
Reply With Quote
  #26  
Old 02-28-2002, 03:36 AM
Lucky Lucky is offline
 
Join Date: Dec 2001
Posts: 234
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great work my friend.
Very simple to install.

Just wondering though, I am using vb2.2.2 along with vbportal and I want to have the weather box on the index page (not http://www.mysite.com/forums/index.php but rather http://www.mysite.com/index.php) like you have. Where should I place the weather_includes.php file? and what else do I have to do?

TIA
Reply With Quote
  #27  
Old 02-28-2002, 05:18 AM
JJR512's Avatar
JJR512 JJR512 is offline
 
Join Date: Oct 2001
Location: Glen Burnie, MD, USA
Posts: 710
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If it is just the index.php file you want it on, you should put a require statement for that file in index.php, probably at the top under the statement for global.php. Edit the templates to how you want them, then put $weather in the forumhome template where you want the weather box to be.

When I'm editing the template of something that's going to get used in another template, as is the situation here, what I do is go to the page that's made by the main template first--in this case, index.php--then save the page as a plain text or HTML-only file (not as Web page, complete). Then I open that file in a browser as well as a text editor, and manually write into the file the basic HTML that would make the new feature show up. This gives me the framework of the template that will be included on the main template, which in this case the template getting included is homeindex_left_weather. Then I copy that HTML framework to a new blank text file, copy the variables from the sample template (the one I provided in the ZIP called homeindex_left_weather.txt) to the places they should go in the framework, and that gives me my template. All that's left is to create the new template in the admin cp, name it the right name, and copy the contents from the text editor.
Reply With Quote
  #28  
Old 02-28-2002, 09:57 AM
Lucky Lucky is offline
 
Join Date: Dec 2001
Posts: 234
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not sure if I made myself clear or maybe I'm just tired, but are you replying to me? And if so, you know that I have vbportal, and I want to have it on my index.php page for vbportal. I have tried what you stated and I have got nowhere. On your site you are running vbportal right? Cause I would like this on my front page, not the forum at all.

TIA
Reply With Quote
  #29  
Old 02-28-2002, 02:58 PM
JJR512's Avatar
JJR512 JJR512 is offline
 
Join Date: Oct 2001
Location: Glen Burnie, MD, USA
Posts: 710
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, I am not running vbPortal.

I misunderstood you to say you wanted this hack to appear on a page that was separate from your vbPortal system. If you want it on a vbPortal page...there is an add-on moduled called MyWeather for vbPortal, you can download it from their website in their downloads area. That is specifically written to work with vbPortal, whereas my hack is only written to integrate with vBulletin. I have no idea how you would integrate my hack into vbPortal.
Reply With Quote
  #30  
Old 02-28-2002, 07:28 PM
JJR512's Avatar
JJR512 JJR512 is offline
 
Join Date: Oct 2001
Location: Glen Burnie, MD, USA
Posts: 710
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is a small mistake in the file called weather_include.txt that's in this hack's ZIP file. Some of you may have put this text inside another PHP file, or made the file into a PHP file and included it from another PHP file. The mistake was the ommission of two lines, one of which causes the date and time of the weather data update (the time AccuWeather released the data) to not show up for the weather feature box or section that you put on another page (using the homeindex_left_weather template), and the other missing line causes the text of the weather type (like partly sunny or rain) to show up under the icon.

The ZIP file will be updated with the correceted file and re-posted above. However, if you already have weather01a.zip, you do not need to redownload it.

Just find this in the code from that file:
PHP Code:
$weatherdata[humidity] = $weather[humidity];
$weatherdata[realfeel] = convert_temp($weather[realfeel],$usersettings[tpc]);

fclose($rawdata); 
Change it to this:
PHP Code:
$weatherdata[humidity] = $weather[humidity];
$weatherdata[realfeel] = convert_temp($weather[realfeel],$usersettings[tpc]);
$weatherdata[lastup] = $weather[lastup];
$weatherdata[context] = $weather[context];

fclose($rawdata); 
Do NOT make this change to weather.php as it already has the missing line.
Reply With Quote
  #31  
Old 03-01-2002, 02:51 AM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this is a great hack. I wish someone post an alternate template idea for frontpage.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:45 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04346 seconds
  • Memory Usage 2,328KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete