The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
vB Weather: Give your members current weather and forecasts! Details »» | |||||||||||||||||||||||||||
vB Weather: Give your members current weather and forecasts!
Developer Last Online: Jun 2006
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
|
Comments |
#62
|
|||
|
|||
Quote:
|
#63
|
||||
|
||||
Yes, you can change the default setting of New York City.
The default settings are the settings for the userid of 0 in the weather_usersettings table. If you have a tool such as phpMyAdmin, and can browse that table, you would see that for userid=0, the accid field is NYC. You would change that field (the accid field) to the city code of whatever city you want as the default. To find the city code, look in the weather_city table, find the city name (city_title), and remember the city code (accid). Then change the code for userid 0 in the weather_usersettings table. Another way to find the city code, and this is probably easier, is to set your own settings to the city you want as the default, then look it up in your record in the weather_usersettings table (find your userid there and remember the accid value by it), then change the code for userid=0. If you don't have phpMyAdmin, but can run queries on the database, here's another way to do it. Set your own settings to the city you want as the default. After saving your settings, go to modify them, but view the source code for the page, and search for the name of the city you selected. When you find it in the source code, look a little bit before the city name, and you should see something like, "<option value="xxxx" selected>your city name here". Note what it says inside the quotes for value (where I put xxxx in the example). Then, run this query on the database: UPDATE weather_usersettings SET accid='xxxx' WHERE userid=0; (where xxxx is the value from before). If you can't run queries directly on the database, this should work. Get the accid for the city you want using the method I described in the previous paragraph. Then, create a new file like this: PHP Code:
I'm sure I've managed to make this as confusing as possible, so I hope you can understand it. |
#64
|
|||
|
|||
I have PHPMYADMIN and was able to change the setting. Worked like a charm! Took 2 seconds. Thanks a bunch!
|
#65
|
||||
|
||||
Just out of curiosity, what did you make as your new default, and how did you choose it?
The only reason I selected New York City was that, with a worldwide membership, and no membership- or website-related reason I could conceive to pick a particular city, I just had a patriotic inspiration and went with NYC. |
#66
|
||||
|
||||
I'm still looking for a way to put this on a non-forumhome page.
I tried the include method and commented the duplicate call to the "weather_functions.php" file in "weather.php" with no luck. I see others are now running this on different pages. Care to share your secrets? Thanks! |
#67
|
||||
|
||||
Someone? Anyone?
|
#68
|
||||
|
||||
Ok, I messed with it some and I've narrowed it down to this. If I let the weather update itself on it's own, it shows up fine on the forumhome. If I try to force an update or modify my settings, it will show all zeros again and also not show the icon for the current weather (but the 5 day forcast is fine). Then, when it automatically updates again 2 hours later, it shows it fine. Can anyone please help me to get this sorted out?
|
#69
|
||||
|
||||
Is this hack being supported anymore or is it just another one gone by the wayside? If it is being supported, will someone please answer our questions so that we can get it running? Thank you.
|
#70
|
||||
|
||||
I don't really know how to solve that problem, since I never had it.
|
#71
|
||||
|
||||
Ok, then can you please tell me EXACTlY how you have it set up on your site so I can make sure I ddin't misinterpret something or do something in the wrong place somehow? The thread was kindof confusing in a few spots. Could it have anything to do with me running PHP 4.2.1?
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|