This snippet should fit your requirements.
1. Create a new snippet with the code below:
<?php
/*
[!timed_content?
&active_months =`12`
&active_days=`15,16,17`
// &active_days=`all`
&default_chunk=`12pm_2pm_default`
&active_chunk=`12pm_2pm`
!]
* set &active_days=`all` for all days of the month
*/
$default_chunk = isset( $default_chunk ) ? $default_chunk : '';
$active_chunk = isset( $active_chunk ) ? $active_chunk : '';
$active_months = isset( $active_months ) ? explode( ',', $active_months ) : '';
$active_days = isset( $active_days ) ? explode( ',', $active_days ) : '';
$time_details = getdate( $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time'] );
$output ='';
$month_ok;
$day_ok;
if( is_array( $active_months ) ){
$month_ok = ( !in_array( $time_details['mon'], $active_months ) ? FALSE : TRUE );
}
if( is_array( $active_days ) ) {
if( in_array( $time_details['mday'], $active_days ) || $active_days[0] =='all' ){
$day_ok = TRUE;
}
}
$print_chunk = ( $month_ok && $day_ok ? $active_chunk : $default_chunk );
$output .='{{'.$print_chunk.'}}';
/*
getdate() debug
uncomment the following lines to print time info
*/
//$details = print_r( $time_details, true );
//$output .='<p>'.str_replace( '[', '<br>[', $details ).'</p>';
return $output;
?>
2. Using the example snippet call at the top of the snippet code, modify the snippet params to suit and add the snippet call wherever you want the chunk to appear.
3. You can also just set all the default params in the snippet code and make a call like so:
// snippet call
[!timed_content!]
// snippet params
$default_chunk = isset( $default_chunk ) ? $default_chunk : '12pm_2pm_default';
$active_chunk = isset( $active_chunk ) ? $active_chunk : '12pm_2pm';
$active_months = isset( $active_months ) ? $active_months : '12';
$active_days = isset( $active_days ) ? $active_days : '1,3,5,7,10';
Hope that helps
[ed. note: breezer last edited this post 13 years, 10 months ago.]