WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Weather for a specific date

[Resolved] Weather for a specific date

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author tuxlog
    Participant

    @tuxlog

    No, the plugin won’t do that. But it should be easy to achieve if you use wp-forecast via sidebar.php because you know how many days of forecast the weather provider delivers and you should know which date you want.

    Saying you have accuweather with nine days of forecast. Today is the 2013-01-25 and you want to see the 2013-01-30.

    Then you have to build something like this

    $daydiff=(strtotime(‘2013-01-30’) – strtotime(‘2013-01-25’))/86400
    If ($daydif <= 9) {
    wp_forecast(‘A’);
    } else {
    echo “No weather data yet”;
    }

    It calculates the differenz between the to dates and if it is lesser than the days of forecast available it shows the widget else showing no weather data yet

    KingShinobi
    Member

    @kingshinobi

    ok that sounds good, but it still display todays forecast instead the one from 2013-01-30 although it should already be available.

    KingShinobi
    Member

    @kingshinobi

    ok if i activate all days, it displays me all weather infos up until the desired date, but I only want to show the specific day.

    i guess i have to pass wp_forecast(‘A’) some parameters to only display the forecast with the correct date, but I don’t know how to filter that.

    Plugin Author tuxlog
    Participant

    @tuxlog

    Ah, no I see what you want to achieve.
    Well, this is not a feature at the moment. You can’t select only one day. But maybe I have a workaround for you:

    Create nine widgets, widget A shows day 1, widget B shows day 2, ….
    Then you can calculate which widget is to use to show the day you want.

    An example:
    calculate how many days apart from today you wanted day is.
    use the widget corresponding to this day, e.g. widget D for day 4

    This may work.

    KingShinobi
    Member

    @kingshinobi

    hi,

    thanks for the reply. Your idea could be managable, but maybe there is another solution.

    How are the nine days forecast displayed? Is it a loop that repeats up to nine times? If yes, then I could try to hook into the loop and just look for the date of each day and if it the correct one, display it. All other days should just not be displayed. For that I would need to know, if the date is stored in a variable, whats the name of it and where I can find it. I hope you can help me a little with that and maybe implement it into your plugin at some point. I will be happy to give you my solution if I get it to work.

    Plugin Author tuxlog
    Participant

    @tuxlog

    You can find all the code to display the weather in wp-forecast-show.php
    Look for “output forecast” around line 350. There is a loop with variable $i which prints the forecast You can get the date with $w[‘fc_obsdate_’.$i].

    I am not sure about integrating this interesting but exotic feature but will think about it.

    KingShinobi
    Member

    @kingshinobi

    alright, i will do my best and keep you updated. i’m surprised to nobody seems to need such a feature. for an event organisator thats a great feature to show the weather for the upcoming event.

    mischkaffee
    Participant

    @mischkaffee

    I just registered to ask if you could add this feature. It would be very useful, especially if it could serve as a guide to attendees before the event, and as a record of the day’s weather after the event.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] Weather for a specific date’ is closed to new replies.