Today button in calendar

5 posts by 2 authors in: Forums > CMS Builder
Last Post: October 11, 2019   (RSS)

Hi, I am using the Zickey Calendar 5 and it is working well but can anyone tell me how I can put in a "Today" button, so when you click it it will take you to todays day, and how can I highlight todays date. Thank you in advance

By daniel - October 9, 2019

Hi MercerDesign,

The calendar page by default shows the current month, so you can likely just link to the main calendar URL to get to "Today"

From what I can see there's no standard way to "highlight" a specific day, so you'll need to figure out how you want to change the CSS (style attribute, class, etc.). You can use the following in the calendar loop to check if it's listing today:

if ($cMonth == date('n') && $cYear == date('Y') && $date == date('j')) {
 // your code
}

This can the calendar loop below the line with "$day=$i-$startday+1;"

Let me know if that helps get this done, or if you have any questions!

Thanks,

Daniel
Technical Lead
interactivetools.com

By daniel - October 10, 2019

Hi MercerDesign,

With your code, you should be able to do something like changing this line:

echo "<td class='CalDates'>". $day . "<br />";

To this:

if ($cMonth == date('n') && $cYear == date('Y') && $date == date('j')) {
  echo "<td class='CalDates today'>". $day . "<br />";
} else {
  echo "<td class='CalDates'>". $day . "<br />";
}

You could then use a ".today" CSS class to change the styling for that day. 

Let me know if that clears it up, or if you have any more questions!

Thanks,

Daniel
Technical Lead
interactivetools.com

Perfect, it works now. THANK YOU