Seite 1 von 1

Calendar logic - if today add button to tomorrow

Verfasst: Mi 14. Dez 2011, 17:55
von Michael_S
Hi,

I would like to use a if statement to add a radio button to calendar days but I'm having problems with the logic. The logic in plain English would be:

IF TODAY ADD BUTTON TO TOMORROW

I can add radio buttons to all future Tuesdays but can't workout how to add the radio button to Tuesday in the same week if the day is Monday and the hour pre-noon (<12). I guess I would need a nested if statement for this but can't work out the logic.

Any help or pointers would be appreciated.

Code: Alles auswählen

<?php

// IF MONDAY & PRE-NOON (<12)
if ((date("Y-m-d",$GLOBALS["lv"]->calendar_struct["date"]) == $today) && 
(date("l",$GLOBALS["lv"]->calendar_struct["date"]) == 'Monday') && 
($hour < '12')) { 

// --- ADD RADIO BUTTON FOR NEXT DAY (TUESDAY)

// if statement
echo '[radio button]';
// end if statement

} elseif (
// ADD RADIO BUTTON FOR FUTURE TUESDAYS
(date("Y-m-d",$GLOBALS["lv"]->calendar_struct["date"]) > $today) && 
(date("l",$GLOBALS["lv"]->calendar_struct["date"]) == 'Tuesday')
) {
echo '[radio button]';
};

?>
This is a PHP question but would be useful for anyone using the calendar function.

Re: Calendar logic - if today add button to tomorrow

Verfasst: Mi 14. Dez 2011, 22:32
von mokraemer
For your simple question the code looks ways to complicated, so I'm not sure if I understood what you wanted.
If you just want to add a button to the next day if the shown date is today, the logic is only

Code: Alles auswählen

<we:ifCurrentDate>
...
</we:ifCurrentDate>
Currently I don't understand why are you extracting the weekday.

Re: Calendar logic - if today add button to tomorrow

Verfasst: Mi 14. Dez 2011, 23:16
von Michael_S
Hi,

I wish it was as simple as just showing the current day :-(

The calendar is being used for fresh food products which can only be delivered on specific days of the week, the web user can also select a next day delivery if the order is placed before 12 midday. To make things more complicated the delivery days change depending on the product.

When I have worked out the logic or we tags I will present a radio button for the web user to select his/her preferred delivery day.
mokraemer hat geschrieben:For your simple question the code looks ways to complicated, so I'm not sure if I understood what you wanted.
If you just want to add a button to the next day if the shown date is today, the logic is only

Code: Alles auswählen

<we:ifCurrentDate>
...
</we:ifCurrentDate>
Currently I don't understand why are you extracting the weekday.