Change object relations from template

Author Message

David Boman

Saturday 09 September 2006 8:17:29 am

Hi,

For the moment I'm working on a membership management system on my site. I have the standard user class and two new classes; 'payment' which stores payments made by the user - it has attributes for amount, date and an object relation attribute pointing to the user who owns the payment. Also a 'membership' class containing membership information like status (aktive, inactive etc) and object relations attribute pointing to the member and to the payment representing the membership fee.

Currently I have the following line view template which will list all members and their corresponding payments (when called from a surronding view template). It also has an action to delete the membership fee but this is were the problems come in...

Currenly the payment object gets deleted (natually, cause I'm calling the action/remove) but what I want to accomplish is that I just want to remove the relation to that payment instead. How to I accomplish this in my input form? Somehow I want to modify the membership object but I don't want to call the edit template for that object - just change the value redisplay the listing again. Any ideas?

{def $payment_object_id_array=$node.object.data_map.payment.content.relation_list}
{foreach $payment_object_id_array as $payment_object_key => $payment_object_id}
	<tr>
		<td>
			{def $user_object_id=$node.object.data_map.user.content.id}
			{def $user_object=fetch( 'content', 'object', hash( 'object_id', $user_object_id ) )}
			{def $user_node=fetch( 'content', 'node', hash( 'node_id', $user_object.main_node_id ) )}
			{if $payment_object_key|eq( '0' )}
				<a href='/{$user_node.url_alias}'|ezurl()>{$user_object.name}</a>
			{/if}
		</td>
		<td>
			{def $payment_node=fetch( 'content', 'node', hash( 'node_id', $payment_object_id.node_id ) )}
			<a href={$payment_node.url_alias|ezurl()}>{$payment_node.object.data_map.payment_amount.content} kr</a>
		</td>
		<td>
			{def $payment_date=$payment_node.object.data_map.payment_date.content}
			{$payment_date.year}-{$payment_date.month}-{$payment_date.day}
		</td>
		<td>
			<form name="payment_{$payment_node.node_id}" method="post" action={'/content/action'|ezurl}>
				<input type="hidden" name="ContentNodeID" value="{$payment_node.node_id}" />
				<input type="hidden" name="ContentObjectID" value="{$payment_node.object.id}" />
				<input type="hidden" name="ActionRemove" value="Remove" />
				<a href="#" onclick="document.forms['payment_{$payment_node.node_id}'].submit();return false;">Delete</a>
			</form>
	</tr>
{/foreach}

David Boman

Wednesday 13 September 2006 11:34:20 pm

No one that have any ideas? Have I been thinking completly wrong or am I just not making my self clear?

Xavier Dutoit

Thursday 14 September 2006 1:14:58 am

Hi,

Not sure what you want to do. Anyway, you can use enhanced object relation for instance, to get a list of all the payments and check/uncheck them to associate (related object) to a member.

When you uncheck a payment, it just deletes the relation, not the payment.

Why don''t you store the payments under each member ? Seems easier to me.

X+

http://www.sydesy.com

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 11:27:30
Script start
Timing: Jan 18 2025 11:27:30
Module start 'layout'
Timing: Jan 18 2025 11:27:30
Module start 'content'
Timing: Jan 18 2025 11:27:30
Module end 'content'
Timing: Jan 18 2025 11:27:30
Script end

Main resources:

Total runtime0.0171 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 588.0156152.6250
Module start 'layout' 0.00720.0030 740.640639.4453
Module start 'content' 0.01020.0045 780.085993.3672
Module end 'content' 0.01460.0024 873.453134.3047
Script end 0.0171  907.7578 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002916.8626140.0002
Check MTime0.00158.4807140.0001
Mysql Total
Database connection0.00127.295610.0012
Mysqli_queries0.003017.609030.0010
Looping result0.00000.080810.0000
Template Total0.001810.610.0018
Template load0.00126.986510.0012
Template processing0.00063.615110.0006
Override
Cache load0.00095.315410.0009
General
dbfile0.00021.384280.0000
String conversion0.00000.062740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs