Forums / Developer / Attend a event

Attend a event

Author Message

Steffen Amundsen

Friday 30 January 2009 5:14:27 am

I have a eventcalender. And I would like users to attend a event. I have created a new class called "attend". I thougt it would be a good idea just to let users create this class under the appropiate event, and then use a fetch to see who is attending.

Now my problem is how to make sure users only can create this class ONCE under each event, and how to let them delete it (if startdate is not passed).

So, how can I test if the current user have already created a child under the current node?

Steffen

Kristof Coomans

Friday 30 January 2009 6:17:03 am

Hi Steffen

You can do this in the template, by fetching the "attend" objects that have the current user as owner. If the count of the results is 0, you can show the create button, otherwise you can show the current object together with an "edit" button or link.

See http://ez.no/doc/ez_publish/technical_manual/4_0/reference/modules/content/fetch_functions/list#eztoc87605_0_0_1, under "Filtering on a non-attribute". The current user you can fetch with the user/current_user fetch function, see http://ez.no/doc/ez_publish/technical_manual/4_0/reference/modules/user/fetch_functions/current_user.

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

Steffen Amundsen

Friday 30 January 2009 6:50:44 am

Thanks.

I am kind a new to Ez, but I try this so far:

 {def $count=fetch( 'content', 'list_count', hash( 'parent_node_id', $node.node_id ) )}

{section show=$count|gt(0)}
 some form here..
{/section}

Now how to test for which user?

Steffen Amundsen

Friday 30 January 2009 7:21:02 am

I think I got it:

{def $user=fetch( 'user', 'current_user' )}
{def $count=fetch( 'content', 'list_count', hash( 
			'parent_node_id', $node.node_id,
			'attribute_filter',$user,
			depth,2,
            class_filter_type, include,
            class_filter_array, array( 'attend' )) )}

{section show=$count|gt(0)}
har meldt på
{section-else}
har ikke
{/section}

Thanks