Forums / Developer / Custum template trouble

Custum template trouble

Author Message

Steph A

Tuesday 06 December 2005 3:58:15 am

This template was ment to show "events" between a "event_start" and "event_stop" date. But I have realized that it has got some fault to it.

Lets say that todays date/time is: 06.12.2005 13.00

We then have a event that starts at 06.12.2005 15.00 and ends at 07.12.2005 15.00
This event will show on both today and tomorrow.

BUT, if we have a event that starts 01.12.2005 15.00 and ends 20.12.2005 15.00 this wil NOT show today.

Anyone that could help me?

{* code for today *}
{let timestamp=maketime()      
current=gettime($timestamp)      
x=0      
start = maketime( 0, 0, 0, $current.month, $current.day, $current.year )      
end = maketime( 23, 59, 59, $current.month, $current.day|sum( $x ), $current.year )      
events = fetch( 'content', 'list',          
hash(                
'parent_node_id', $node.node_id,                
'attribute_filter', array(                        
'or',                        
array( 'event/event_start', 'between', array( $start, $end ) ),                        
array( 'event/event_end', 'between', array( $start, $end ) )                     
)               
)             
)  
}  
{foreach $events as $event}     
{node_view_gui view='line' content_node=$event}  
{/foreach}  
{/let}


{* code for tomorrow *} 

{let timestamp=maketime()      
current=gettime($timestamp)      
x=1
y=1      
start = maketime( 0, 0, 0, $current.month, $current.day|sum( $y ), $current.year )      
end = maketime( 23, 59, 59, $current.month, $current.day|sum( $x ), $current.year )      
events = fetch( 'content', 'list',          
hash(                
'parent_node_id', $node.node_id,                
'attribute_filter', array(                        
'or',                        
array( 'event/event_start', 'between', array( $start, $end ) ),                        
array( 'event/event_end', 'between', array( $start, $end ) )                     
)               
)             
)  
}  
{foreach $events as $event}     
{node_view_gui view='line' content_node=$event}  
{/foreach}  
{/let}

{* ...and so on *}

Kristof Coomans

Tuesday 06 December 2005 4:23:33 am

I think this will do it:

...
'attribute_filter', array(                    
    'and',                        
    array( 'event/event_start', '<=', $end ),                        
    array( 'event/event_end', '>=', $start )
)
...

 

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org