Show "events" for the next X days

Author Message

Steph A

Monday 03 October 2005 4:08:56 am

I have a class called "event" with two date attributes - "event_start" and "event_stop".

How can I show all the "events" for the next X days, including events already started (under progress).

Anyone done this before, and willing to share the template - or lead me into the right direction?

I have been looking around in the forum for ideas/solutions, but with no luck.

Any help would be deeply appreciated..

Kristof Coomans

Monday 03 October 2005 4:47:22 am

I think this should work:

{let timestamp=maketime()
     current=gettime(timestamp)
     x=5
     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_start', 'between', array( $start, $end ) ),
                       array( 'event_end', 'between', array( $start, $end ) )
                    )
              )
            )
}

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

Steph A

Monday 03 October 2005 5:41:53 am

Thank you. But I have another possible stupid question (I quite a newbie!):

How do I make this result show nodes line-view?

{node_view_gui view=line content_node=$:item}

or something?

Kristof Coomans

Monday 03 October 2005 5:48:48 am

{foreach $events as $event}
    {node_view_gui view='line' content_node=$event}
{/foreach}

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

Steph A

Monday 03 October 2005 6:02:52 am

Thanks for your patient with me.

But I am afraid I dont understand this code, and where to put what.

This is the code I am trying to use as an "view/full" overide:

{*?template charset=utf-8?*}
{let timestamp=maketime()
     current=gettime(timestamp)
     x=5
     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_start', 'between', array( $start, $end ) ),
                       array( 'event_end', 'between', array( $start, $end ) )
                    )
              )
            )
{foreach $events as $event}
    {node_view_gui view='line' content_node=$event}
{/foreach}

{/let}

Forever grateful if you can help me.... ;)

Kristof Coomans

Monday 03 October 2005 6:35:50 am

I made a little mistake in the attribute filter, I forgot to prepend the class identifiers.

{*?template charset=utf-8?*}
{let timestamp=maketime()
     current=gettime(timestamp)
     x=5
     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}

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

Steph A

Monday 03 October 2005 6:47:41 am

I just get a blue document icon showing, when using this code:

{let timestamp=maketime()
     current=gettime(timestamp)
     x=5
     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}

**DEBUG INFO**

Undefined variable: var in c:\ezpublish\ezpublish\var\news\cache\template\compiled\full_view_kalender-7ce7fd557d332cd3d382669e60c7eed2.php on line 49

Undefined variable: var in c:\ezpublish\ezpublish\var\news\cache\template\compiled\full_view_kalender-7ce7fd557d332cd3d382669e60c7eed2.php on line 51

Kristof Coomans

Monday 03 October 2005 7:02:10 am

Can you place this before the <b>foreach</b> loop:

{$events|count}

What do you get now?

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

Steph A

Monday 03 October 2005 7:08:14 am

The blue icon is gone, and nothing shows.

DEBUG

array_keys(): The first argument should be an array in c:\ezpublish\ezpublish\var\news\cache\template\compiled\full_view_kalender-7ce7fd557d332cd3d382669e60c7eed2.php on line 62

Kristof Coomans

Monday 03 October 2005 7:23:21 am

Some fixes in the code, this time I've tested it myself:

{let timestamp=maketime()
     current=gettime($timestamp)
     x=5
     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}

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

Steph A

Monday 03 October 2005 7:31:18 am

Okay, all previous debug error is gone.

One warning: "Attribute filter returned false"

Nothing shows....

Kristof Coomans

Monday 03 October 2005 7:39:46 am

Replace event_end with event_stop.

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

Steph A

Monday 03 October 2005 7:47:41 am

YEEES IT WORKS!

You are my man ;)

Thank you VERY much!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:39:42
Script start
Timing: Jan 18 2025 19:39:42
Module start 'layout'
Timing: Jan 18 2025 19:39:42
Module start 'content'
Timing: Jan 18 2025 19:39:43
Module end 'content'
Timing: Jan 18 2025 19:39:43
Script end

Main resources:

Total runtime0.7064 sec
Peak memory usage4,096.0000 KB
Database Queries87

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 587.9063152.6250
Module start 'layout' 0.00570.0026 740.531339.4453
Module start 'content' 0.00830.6966 779.9766655.8906
Module end 'content' 0.70500.0014 1,435.867228.1563
Script end 0.7064  1,464.0234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4815160.0002
Check MTime0.00140.1929160.0001
Mysql Total
Database connection0.00060.089510.0006
Mysqli_queries0.624388.3719870.0072
Looping result0.00080.1164850.0000
Template Total0.673895.420.3369
Template load0.00200.277220.0010
Template processing0.671895.102020.3359
Template load and register function0.00020.029310.0002
states
state_id_array0.00220.318110.0022
state_identifier_array0.00140.194920.0007
Override
Cache load0.00170.2425600.0000
Sytem overhead
Fetch class attribute can translate value0.00090.134520.0005
Fetch class attribute name0.00140.1933140.0001
XML
Image XML parsing0.00070.094520.0003
class_abstraction
Instantiating content class attribute0.00000.0050190.0000
General
dbfile0.00090.1236160.0001
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
13content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
16content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 45
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs