Current user is loggin and is owner of an object.

Author Message

laurent le cadet

Monday 30 October 2006 9:01:54 am

Hi,

I allow creation of one type of object for user which are loggin (curriculum vitae).
I want to know if they already published there CV (only one per user) or not but don't know exactly how to do it.

I'm thinking about something like that but some piece of code are missing :

{section show=$current_user.is_logged_in}
{set cv=fetch(content, list, hash (parent_node_id, 153,
                                class_filter_type, include,
                                class_filter_array, array( 'cv' )......How to fetch curent is owner of a CV ? )) }

{set list_count=fetch_alias( children_count, hash( parent_node_id, 153,
                                class_filter_type, include,
                                class_filter_array, array( 'cv' ) ))}

{section show=$list_count|gt(0)}
<a href="/content/view/full/153" />My CV</a>
{section-else}
<form method="post" action={"content/action"|ezurl}>
		<input type="hidden" name="ClassIdentifier" value="cv" />
		<input type="hidden" name="NodeID" value="153" />
		
		<input  class="searchbutton" type="submit" name="NewButton" value="Create CV" />
</form>
{/section}

Any hint ?

Regards.

Laurent

Claudia Kosny

Wednesday 01 November 2006 9:06:46 am

Hi Laurent

I would try to add an attribute filter that filters by owner. See example 16 on http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/list

Claudia

laurent le cadet

Thursday 02 November 2006 2:19:24 am

Thanks again Claudia,

This code do the trick :

{def $count=fetch( 'content', 'list_count', hash( 'parent_node_id', 153,
'attribute_filter', array(
                                  array( 'owner',
                                   '=',
                                  $current_user.contentobject_id ) ) ) )}
			{section show=$count|eq(0)}
			<form method="post" action={"content/action"|ezurl}>
				<input type="hidden" name="ClassIdentifier" value="cv" />
				<input type="hidden" name="NodeID" value="153" />
				<input  class="searchbutton" type="submit" name="NewButton" value="Create CV" />
			</form>
			{/section}
{undef $count}

Laurent

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 15:51:13
Script start
Timing: Jan 18 2025 15:51:13
Module start 'layout'
Timing: Jan 18 2025 15:51:13
Module start 'content'
Timing: Jan 18 2025 15:51:14
Module end 'content'
Timing: Jan 18 2025 15:51:14
Script end

Main resources:

Total runtime0.7317 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 588.0625152.6406
Module start 'layout' 0.00610.0027 740.703139.4766
Module start 'content' 0.00880.7215 780.1797507.2891
Module end 'content' 0.73030.0013 1,287.468812.1250
Script end 0.7316  1,299.5938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4688160.0002
Check MTime0.00140.1973160.0001
Mysql Total
Database connection0.00080.112910.0008
Mysqli_queries0.683893.4541570.0120
Looping result0.00050.0724550.0000
Template Total0.698195.420.3491
Template load0.00200.269420.0010
Template processing0.696195.143020.3481
Template load and register function0.00010.014210.0001
states
state_id_array0.00130.171810.0013
state_identifier_array0.00070.096420.0004
Override
Cache load0.00160.2227220.0001
Sytem overhead
Fetch class attribute can translate value0.00060.076520.0003
Fetch class attribute name0.00170.226440.0004
XML
Image XML parsing0.00050.066920.0002
class_abstraction
Instantiating content class attribute0.00000.001550.0000
General
dbfile0.00070.0907160.0000
String conversion0.00000.000940.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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/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: 16
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs