Highlighting the date that currently browsing
WordPress Event Management, Calendars & Registration › Forums › General Question › Highlighting the date that currently browsing
This topic contains 10 replies, has 2 voices, and was last updated by  Iurii Smuglov 12 years ago.
- 
		AuthorPosts
- 
		
			
				
September 5, 2013 at 9:54 am #7196#wp-calendar .event is highlighting all dates with events, but i need to highlight only date that currently browsing. - 
		This topic was modified 12 years, 1 month ago by Stephen Harris. 
 Iurii Smuglov September 5, 2013 at 10:07 am #7197And could you give me advice how ho highlight weekend names and dates? Iurii Smuglov September 5, 2013 at 1:18 pm #7201Hi Lurii, I’d recommend against using #wp-calendaras this maybe removed in a later version (As it potentially conflicts with the standard WordPress calendar). To target the event widget a calendar, use.eo_widget_calendarinstead.Targeting weekends is not supported by all browsers. I’ll looking into adding classes to make cross-browser support possible. However on modern browsers (everything except IE8 and earlier) the following should work: //The following assumes Saturday & Sunday are the last two columns on the calendar //(e.g. columns 6 & 7). Change as appropriate //Target weekend dates .eo_widget_calendar table tr td:nth-child(6), .eo_widget_calendar table tr td:nth-child(7){ background:#fff79a } //Target weekend header .eo_widget_calendar table tr th:nth-child(6), .eo_widget_calendar table tr th:nth-child(7){ background:#ffe79a; }Stephen Harris September 5, 2013 at 3:51 pm #7204Thanks Stephen. 
 Need to add -a- to weekend dates in that code.//The following assumes Saturday & Sunday are the last two columns on the calendar 
 //(e.g. columns 6 & 7). Change as appropriate/* Target weekend dates / 
 .eo_widget_calendar table tr td:nth-child(6) a,
 .eo_widget_calendar table tr td:nth-child(7) a{
 background:#fff79a }<br />
 / Target weekend header */
 .eo_widget_calendar table tr th:nth-child(6),
 .eo_widget_calendar table tr th:nth-child(7){
 background:#ffe79a; }Iurii Smuglov September 5, 2013 at 3:51 pm #7205Thanks Stephen. Works graet, but need to add -a- to weekend dates in that code. /* Target weekend dates / .eo_widget_calendar table tr td:nth-child(6) a, 
 .eo_widget_calendar table tr td:nth-child(7) a
 { background:#fff79a }
 / Target weekend header */
 .eo_widget_calendar table tr th:nth-child(6),
 .eo_widget_calendar table tr th:nth-child(7)
 { background:#ffe79a; }- 
		This reply was modified 12 years, 1 month ago by Iurii Smuglov. 
- 
		This reply was modified 12 years, 1 month ago by Iurii Smuglov. 
 Iurii Smuglov September 6, 2013 at 1:20 pm #7227And what about highlighting date that currently browsing? 🙂 Iurii Smuglov September 6, 2013 at 7:07 pm #7233Unfortunately I do not think that will be possible. The calendar is cached for performance so it wouldn’t be possible to add a class e.g. vewing-this-dateto the appropriate cell when the HTML is being generated (because it won’t always be being generated – most of the time it’ll be fetched from cache).However, if I were to add date data attributes to the cells (e.g. data-eo-wc-date="2013-09-06") then it would be possible to dynamically generate a line of CSS:[data-eo-wc-date="YYYY-MM-DD"] { /* Styles */ }where YYYY-MM-DDis replaced by the date being viewed. You can get the date being viewed in that format via this function: http://codex.wp-event-organiser.com/function-eo_get_event_archive_date.html.I’ll aim to get those data-attribute tags in the 2.3 release and then write up a post on how to do this. Stephen Harris September 28, 2013 at 3:32 pm #7485Since (EO) 2.3 you can do this with There are two problems here: the current day is typically highlighted (with the class .today– assuming the theme uses that class). So the calendar may end up having two dates highlighted. That’s not really much of any issue if different stylings are used.The bigger issue is that the calendar is cached. And although its likely to be regularly cleared, it may mean when navigating between days, the incorrect date is highlighted. However, with 2.3 there’s a way around this. Data attributes are added to each cell of the form: data-eo-wc-date="yyyy-mm-dd"The following code can therefore dynamically style the appropriate cell: add_action( 'wp_head', 'my_style_currenty_viewed_day' ); function my_style_currenty_viewed_day(){ if( eo_is_event_archive( 'day' ) ){ $date = eo_get_event_archive_date( 'Y-m-d' ); if( $date ){ ?> <style type="text/css"> .eo_widget_calendar [data-eo-wc-date="<?php echo $date;?>"] { background: red; } </style> <?php } } }Stephen Harris October 18, 2013 at 9:49 am #7807This code doesnt work, unfortunately 🙁 link on October 19th, for example (background: green;) EO – 2.3.2 - 
		This reply was modified 12 years ago by Iurii Smuglov. 
 Iurii Smuglov October 18, 2013 at 9:58 am #7809It’s a caching issue. Try: http://top9oslo.com/events/archive/on/2013/11/24/ (works for me). It should fix itself ~24 hours. Otherwise updating an event should also clear the calendar cache… Stephen Harris October 18, 2013 at 10:11 am #7810Oh, really! It works, except archives of this month, but after updating random event – works everywhere. Thanks a lot! Iurii Smuglov 
- 
		This topic was modified 12 years, 1 month ago by 
- 
		AuthorPosts