Can not fetch my "home made" objects...

Author Message

Milad P

Tuesday 19 December 2006 8:05:04 am

Hi,

I created a simple class which only contains a textinput. Then i created a folder with several of my new class objects. My problem is when i try to fetch information from that node, i got nothing back. It works if i put some other objects (like article, link, folder etc.) but not my new class?

Why? it seems very strange?

This is the code that i use to fetch my objects. I can not find any problems with the code.


        {def $children_count=fetch('content', 'list_count', hash('parent_node_id', 12785 ) ) }
        {def $children=fetch('content', 'list', hash('parent_node_id', 12785) ) }

        {do}
                {def $nr = rand(0,$children_count)}
        {/do while($children[$nr].object.data_map.name.content|null())}
        <b>{"Did you know that"|i18n('chsmisc')}</b>
        {$children[$nr].object.data_map.name.content}



Claudia Kosny

Wednesday 20 December 2006 1:18:49 am

Hi Milad

Is the problem caused by the fetch functions or by the loop? Do you get any messages in debug output?

You cannot use {def ... in a loop as you can define a variable only once in a template. So you either {undef $nr} in the loop again or you put {def $nr = 0} (or so) before the loop and use {set $nr = ...} in the loop.

Check whether $children_count and $children contain anything. Check whether $children[$nr].object.data_map.name exists (maybe you have a typo in your class definition).

Regarding the loop itself: if you just want to have a random node where the attribute name contains something, it might be more efficient to limit the fetch to these noses using the attribute filter and to use the limit and offset parameter to fetch just one node.

For fetching random content see here:
http://ez.no/community/forum/setup_design/how_to_fetch_random_content_3_8/re_how_to_fetch_random_content_3_8

Claudia

Milad P

Wednesday 20 December 2006 5:58:38 am

Hi again,

The problem is in the fetch line. $children and $children_count contains nothing. $children returns a empty array and $children_count = 0.

//Milad

Claudia Kosny

Wednesday 20 December 2006 1:02:34 pm

Hi Milad

Do you see your custom objects in the admin view under the specified parent node?
If not, you have the wrong parent node.
If yes, I think there is something wrong with either the visibility, the permissions or the translations of your custom objects. So add the following parameters to your fetch parameters:

'ignore_visibility' => true(),
'limitation' => array(),
'only_translated' => false()

Clear the cache and try again. Does that help?

Claudia

Milad P

Thursday 21 December 2006 1:18:57 am

Thank you for your advise. It seems that i have forgot to set the proper permissions for my new object. Problem solved.

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:52:43
Script start
Timing: Jan 18 2025 15:52:43
Module start 'layout'
Timing: Jan 18 2025 15:52:43
Module start 'content'
Timing: Jan 18 2025 15:52:44
Module end 'content'
Timing: Jan 18 2025 15:52:44
Script end

Main resources:

Total runtime0.8047 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 589.1484152.6250
Module start 'layout' 0.00590.0031 741.773439.4453
Module start 'content' 0.00900.7944 781.2188495.5859
Module end 'content' 0.80340.0013 1,276.804712.1563
Script end 0.8047  1,288.9609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.3855160.0002
Check MTime0.00130.1601160.0001
Mysql Total
Database connection0.00090.117110.0009
Mysqli_queries0.758394.2290630.0120
Looping result0.00050.0618610.0000
Template Total0.774096.220.3870
Template load0.00200.252620.0010
Template processing0.772095.930620.3860
Template load and register function0.00020.019510.0002
states
state_id_array0.00080.098410.0008
state_identifier_array0.00080.100220.0004
Override
Cache load0.00170.2123330.0001
Sytem overhead
Fetch class attribute can translate value0.00080.098820.0004
Fetch class attribute name0.00090.115350.0002
XML
Image XML parsing0.00020.030020.0001
class_abstraction
Instantiating content class attribute0.00000.001150.0000
General
dbfile0.00060.0741100.0001
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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs