Forums / Setup & design / looping information collections

looping information collections

Author Message

*- pike

Friday 18 August 2006 3:43:20 am

Hi

I must be completely missing the point here.

I have objects with information collectors. They collect information - I can see the collection in the admin (setup/collected info).

To set up some similar display in my design, I assumed a fetch would be available to get the Collected Information from an object or an attribute. Even a fetch to get all collections, or a fetch to get a count of all collections would do. Or some attribute on the object or attribute pointing to the collections of that object or attribute. But there isn't any of those ?

There is

- a fetch for an information collection given the collection id and object id
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/collected_info_collection

- a count fetch for the number of information collections given a object id or attribute id
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/collected_info_count

- a confusing kind of fetch used to do statistics given an attribute id
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/collected_info_count_list

These are all quite useless in a template unless you happen to create a poll :-)

The admin page use a plain sql query behind the scenes, and tuck the results in a template variable before parsing the template. To mimic that, I have to create an extension.

Am I missing something ?

thanks,
*-pike

---------------
The class eZContentObjectTreeNode does.

*- pike

Friday 18 August 2006 5:33:24 am

Found a quick workaround tho

{let collections=array()
	numcollections=fetch( 'content', 'collected_info_count', hash( 'object_id', $node.object.id ))
	collidx=1
}
	{while lt($collections|count(),$numcollections)}
		<!-- checking collection {$collidx} -->
		{set $collection=fetch( 'content', 'collected_info_collection', 
			hash( 'collection_id',$collidx,'contentobject_id', $node.object.id ))}
		{if ne($collection, false())}
			<!-- collection is from this object -->
			{set $collections = $collections | append($collection) }
		{else}
			<!-- collection is not from this object -->
		{/if}
		{set $collidx=inc($collidx)}
	{/while}

      {* now do what you want with all $collections from this $node.object *}
      {foreach $collections as $collection}
            Collection {$collection.id}, {$collection.modified | datetime()  }
      {/foreach}

{/let}


What it does is way ugly .. it loops collidx from 1 to infinity and tries to get a collection from the current node with that collection id. It stops looping when the amount of collections found matches what the "collected_info_count" told us it should be.

Theoretically, this should never give an infinite loop. But I have to trust the inner workings of ezp for that.

---------------
The class eZContentObjectTreeNode does.

*- pike

Friday 18 August 2006 11:25:36 am

There is a little bug in the above

$collection=fetch( 'content', 'collected_info_collection', hash( 'collection_id',$collidx,'contentobject_id', $node.object.id )

returns collection $collidx regardless of $node.object.id, not false()
in ezp 3.7.6

since this 'feature' is not documented,
we should run the test ourself, using

 {if and($collection,eq($collection.contentobject_id, $node.object.id))}
	<!-- collection is from this object -->
       {set $collections = $collections | append($collection) }
{else}
       <!-- collection is not from this object -->
{/if}

and lament the wasted cpucycles ..

---------------
The class eZContentObjectTreeNode does.

*- pike

Friday 18 August 2006 11:34:55 am

after a long day of work, I finally have what I want - a (more or less generic) display of collections created by an object that has a few information collectors.

it seems to me the "information collection" mechanism is a bit underdeveloped. if you ask me, it might as well be skipped in a next version. The concept is confusing.

Looking back, I wish I had just created a plain content class and allow users to create objects of that class in a predestined folder, which
- is easier to setup
- has more options and flexibility
- is easier to understand for an admin

hope it helps anyone,
*pike

---------------
The class eZContentObjectTreeNode does.

*- pike

Friday 18 August 2006 3:15:11 pm

I've put the template source here, but it was too big too be usefull. Too bad there are no attachments in this forum. I felt like sharing today ! Now, I since can not remove this message, I'm typing this here. Ignore :-)

---------------
The class eZContentObjectTreeNode does.

eZ debug

Timing: Jan 30 2025 21:13:08
Script start
Timing: Jan 30 2025 21:13:08
Module start 'content'
Timing: Jan 30 2025 21:13:09
Module end 'content'
Timing: Jan 30 2025 21:13:10
Script end

Main resources:

Total runtime1.2235 sec
Peak memory usage10,240.0000 KB
Database Queries198

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0077 587.9453370.2969
Module start 'content' 0.00771.0855 958.24224,309.1094
Module end 'content' 1.09320.1303 5,267.35161,276.2656
Script end 1.2234  6,543.6172 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00510.4204210.0002
Check MTime0.00140.1149210.0001
Mysql Total
Database connection0.00060.052110.0006
Mysqli_queries1.088488.95681980.0055
Looping result0.00160.13221960.0000
Template Total1.173495.920.5867
Template load0.00200.166120.0010
Template processing1.171495.740420.5857
Template load and register function0.00130.108810.0013
states
state_id_array0.00180.147710.0018
state_identifier_array0.00150.124720.0008
Override
Cache load0.00160.1344440.0000
Sytem overhead
Fetch class attribute can translate value0.00240.194320.0012
Fetch class attribute name0.00170.135050.0003
XML
Image XML parsing0.00030.025820.0002
class_abstraction
Instantiating content class attribute0.00000.000750.0000
General
dbfile0.01030.8412210.0005
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
15content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 33
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs