Share » Forums » General » EZselection and fetching data from...

EZselection and fetching data from two classes

EZselection and fetching data from two classes

Wednesday 11 January 2006 3:24:55 am - 10 replies

Modified on Wednesday 11 January 2006 3:50:53 am by Kristoffer Raun

Author Message

Tore Skobba

Wednesday 11 January 2006 3:51:54 am

Hi

You do an switch on: {switch match=$:item.data_map.product.content.0}

Why do you have the last 0? If product is an ezselection then I think you should drop the last 0 and do an check on the actual content of the product.

Kristoffer Raun

Wednesday 11 January 2006 4:19:36 am

Hi and thanks for the fast response

product is not a ezselection
Product (actually called qualified_product) is a class with an selection-attribute that has the indentifier called product .

Without the 0 (zero) i just get all producers

producer1
producer2
producer3

even though that some of them only have "bananas" and not "apples"

the 0 (zero) was something i fould in this post:
http://ez.no/community/forum/developer/ezselection_problems/re_ezselection_problems

I've also tried "another" approach when fetching to exclude producers without apples

{let category=fetch('content','list',hash(parent_node_id,132,depth, 4,class_filter_type,"include",class_filter_array,array(16,17),'attribute_filter_array', array('and',array( 'qualified_product/product', '=', '1' ),array('producer/producer_name','!=', '0') )))}

same loop as before (only with a zero as the difference) :-)

Thanks again

<i>If you can't describe what you are doing as a process, you don't know what you're doing.</i>
W. Edwards Deming

Tore Skobba

Wednesday 11 January 2006 5:49:11 am

Hmmm well, It is to difficult to read the code from here, I think you should add some debug messages and use the

{$node|attribute(show)}

To se the actual values.. As I know that what you are trying to do is quite possible as I have done something similar for another site. Do {$:item.data_map.product.content.0|attribute(show)} (just remember to limit your loop to 1 or 2, else the debug data might be to much for Apache or your browser.

Kristoffer Raun

Wednesday 11 January 2006 6:18:08 am

I've tried the what you suggested

{section name=Prod loop=$prod max=2}

{switch match=$:item.data_map.product.content}
{case match=0}
				{$:item.data_map.product.content.0|attribute(show)} 								
		
<br>
{/case}
{case}do nothing{/case}	
{/switch}	
		
{/section}

Then i get the following debug
No such attribute for array(6): product
Choose one of following: producer_name, producer_address, producer_phone,
producer_fax, producer_link, producer_image

From my limited knowledge, i guess that there is a problem fetching the class with the ID 16, the product class.
Is this the correct fetching?
class_filter_array,array(17,16) or chould it be
class_filter_array,array(16,17)?

/Kristoffer

<i>If you can't describe what you are doing as a process, you don't know what you're doing.</i>
W. Edwards Deming

Tore Skobba

Thursday 12 January 2006 1:41:32 am

Your error basically says that you are trying to get an non existent attribute (which is also probably why your template code does not do as you want). The $ITEM does NOT have any product assosiated with it, only:

producer_name, producer_address, producer_phone, producer_fax, producer_link, producer_image

Therefore check that you are fetching the correct objects into item.

Remember the: {$:item.data_map.product.content|attribute(show)} will show you what attributes and values there are for the product attribute. Read and understand the output and check you switch case logic afterwards.

class_filter_array,array(16,17) is just fine for fetching all objects with class id 16 and 17.

Cheers
Tore

Kristoffer Raun

Thursday 12 January 2006 2:33:52 pm

I must say that I'm close to giving up.

I can show the relevant information, but even thought that I (at least try to) get some of the data away (all producers that do NOT have apples lets say.) it's apparently fetched.

I can get it to show the producers, and the products, but my role when i want to limit the search to ONLY show the producers with the apples doesn't work

The output is
Producer1
Apples
Apples
Apples
Apples
Apples
Producer2
Apples
Apples
Apples
Apples
Producer3
Apples
Producer4
Producer5
Apples
Apples
Producer6
Producer7

Now you notice Producer 4 and 6. They do NOT have any apples and shouldn't be shown.
The fetchfunction copies the producers without apples (also them with peaches and Oranges), otherwise they wouldn't be shown.
What is happening

my code is here

{let category=fetch('content','list',hash(parent_node_id,132,depth, 4,class_filter_type,"include",class_filter_array,array(16,17),'attribute_filter_array', array('and',array( 'qualified_product/product', '=', '1' ),array('producer/producer_name','!=', '0') )))}


{section name=Cat loop=$category}

{switch match=$Cat:item.data_map.product.content.0}
												{case match=0}
											{section show=$:item.object.data_map.product_category.content.is_empty|not}
            <div class="attribute-long">
                {attribute_view_gui attribute=$:item.object.data_map.producer_name}
            </div>
        {/section}{attribute_view_gui attribute=$:item.object.data_map.producer_name}{attribute_view_gui attribute=$:item.object.data_map.product}
{attribute_view_gui attribute=$:item.object.data_map.product_category}<br>
											{/case}
											{case}{/case}
							{/switch}	

{/section}







{/let}

I have tried the attribute show, but since i can only do it 2-3 times in order to avoid crash, i cannot see whats relevant in the debug since there is a long way down to "Producer4" without apples.
Also notice that the Section apparently loops more than one time (two times), Is this due to the fetching of two classes and that EZ wants to make the loop 2 times.

I'm unfortunately getting more and more tired of things like this. Even though you can do cool stuff with EZ - it's a pain in the *** with things like this!

/Kristoffer

<i>If you can't describe what you are doing as a process, you don't know what you're doing.</i>
W. Edwards Deming

Kristoffer Raun

Thursday 12 January 2006 2:56:25 pm

and now i'm getting an error when trying to work with the admin
Fatal error: Maximum execution time of 60 seconds exceeded in c:\ezpublish\ezpublish\lib\eztemplate\classes\eztemplate.php on line 618
Fatal error: eZ publish did not finish its request

The execution of eZ publish was abruptly ended, the debug output is present below.

eZ debug

Timing: Feb 12 2006 23:58:56
Script start

Notice: eZMySQLDB::query(0.000 ms) query number per page:0 Feb 12 2006 23:58:56
SET NAMES 'utf8'

Timing: Feb 12 2006 23:58:56
Module start 'content'

Warning: eZTemplate:def Feb 12 2006 23:58:56
Variable 'nodeContent' is already defined.

Warning: eZTemplate:def Feb 12 2006 23:58:56
Variable 'nodeContent' is already defined.

Warning: eZTemplate:def Feb 12 2006 23:58:56
Variable 'nodeContent' is already defined.

Warning: eZTemplate:def Feb 12 2006 23:58:56
Variable 'nodeContent' is already defined.

Warning: eZTemplate:def Feb 12 2006 23:58:56
Variable 'nodeContent' is already defined.

Timing: Feb 12 2006 23:58:56
Module end 'content'

Warning: eZTemplate Feb 12 2006 23:58:56
No template could be loaded for "setup/debug_toolbar.tpl" using resource "design"

Timing points:
Checkpoint Elapsed Rel. Elapsed Memory Rel. Memory
Script start 0.0000 sec 0.1929 sec 0.0000KB 0.0000KB
Module start 'content' 0.1929 sec 2.7602 sec 0.0000KB 0.0000KB
Module end 'content' 2.9532 sec 0.0000KB 0.0000KB
Total runtime: 60.0347 sec

Time accumulators:
Accumulator Elapsed Percent Count Average
ini_load
Load cache 0.1917 sec 0.3192% 15 0.0128 sec
Mysql Total
Mysql_queries 4.3255 sec 7.2041% 480 0.0090 sec
Looping result 0.1337 sec 0.2227% 477 0.0003 sec
Template Total 2.6846 sec 4.5% 2 1.3423 sec
Template load 0.5409 sec 0.9009% 3 0.1803 sec
String conversion in template resource 0.0285 sec 0.0474% 16 0.0018 sec
Template parser: create text elements 0.2833 sec 0.4718% 16 0.0177 sec
Template parser: remove whitespace 0.0941 sec 0.1567% 16 0.0059 sec
Template parser: construct tree 1.5824 sec 2.6355% 16 0.0989 sec
Template load and register function 0.0301 sec 0.0502% 11 0.0027 sec
Template processing 2.4419 sec 4.0670% 1 2.4419 sec
override
Cache load 4.3456 sec 7.2376% 678 0.0064 sec
Matching rules 0.0227 sec 0.0377% 10 0.0023 sec
class_abstraction
Instantiating content class attribute 0.0123 sec 0.0204% 2 0.0061 sec
General
String conversion 0.0241 sec 0.0401% 16 0.0015 sec
String conversion w/ mbstring 0.0142 sec 0.0237% 16 0.0009 sec
Total script time: 60.0418 sec

What is wrong here?

<i>If you can't describe what you are doing as a process, you don't know what you're doing.</i>
W. Edwards Deming

Kristoffer Raun

Thursday 12 January 2006 2:59:03 pm

And got in one time - ADMIN is painfully slow
Template processing takes forever????


Timing: Feb 13 2006 00:01:57
Script start
Notice: eZMySQLDB::query(0.000 ms) query number per page:0 Feb 13 2006 00:01:57
SET NAMES 'utf8'
Timing: Feb 13 2006 00:01:57
Module start 'content'
Warning: eZTemplate:def Feb 13 2006 00:01:57
Variable 'nodeContent' is already defined.
Warning: eZTemplate:def Feb 13 2006 00:01:57
Variable 'nodeContent' is already defined.
Warning: eZTemplate:def Feb 13 2006 00:01:57
Variable 'nodeContent' is already defined.
Warning: eZTemplate:def Feb 13 2006 00:01:57
Variable 'nodeContent' is already defined.
Warning: eZTemplate:def Feb 13 2006 00:01:57
Variable 'nodeContent' is already defined.
Timing: Feb 13 2006 00:01:57
Module end 'content'
Timing: Feb 13 2006 00:01:57
End

Timing points:
Checkpoint Elapsed Rel. Elapsed Memory Rel. Memory
Script start 0.0000 sec 0.2019 sec 0.0000KB 0.0000KB
Module start 'content' 0.2019 sec 2.6402 sec 0.0000KB 0.0000KB
Module end 'content' 2.8421 sec 55.6087 sec 0.0000KB 0.0000KB
End 58.4508 sec 0.0000KB 0.0000KB
Total runtime: 58.8743 sec

Time accumulators:
Accumulator Elapsed Percent Count Average
ini_load
Load cache 0.1763 sec 0.2995% 19 0.0093 sec
Mysql Total
Mysql_queries 4.0811 sec 6.9311% 484 0.0084 sec
Looping result 0.1177 sec 0.1998% 479 0.0002 sec
Template Total 58.4542 sec 99.3% 3 19.4847 sec
Template load 0.5607 sec 0.9522% 3 0.1869 sec
String conversion in template resource 0.0364 sec 0.0618% 27 0.0013 sec
Template parser: create text elements 0.5219 sec 0.8864% 27 0.0193 sec
Template parser: remove whitespace 0.1221 sec 0.2074% 27 0.0045 sec
Template parser: construct tree 2.4823 sec 4.2158% 27 0.0919 sec
Template load and register function 0.0434 sec 0.0737% 11 0.0039 sec
Template processing 57.8918 sec 98.3205% 3 19.2973 sec
override
Cache load 4.1425 sec 7.0355% 690 0.0060 sec
Matching rules 0.0310 sec 0.0526% 16 0.0019 sec
class_abstraction
Instantiating content class attribute 0.0177 sec 0.0300% 2 0.0088 sec
General
String conversion 0.0244 sec 0.0415% 27 0.0009 sec
String conversion w/ mbstring 0.0180 sec 0.0305% 27 0.0007 sec
Total script time: 58.8807 sec

<i>If you can't describe what you are doing as a process, you don't know what you're doing.</i>
W. Edwards Deming

Kristoffer Raun

Thursday 12 January 2006 3:01:00 pm

Why is there 490 mysql queries???
Someone sayd somewhere that there was only supposed to be max 3 ?

<i>If you can't describe what you are doing as a process, you don't know what you're doing.</i>
W. Edwards Deming

Tore Skobba

Friday 13 January 2006 2:04:07 am

Hi

The error maxium execution time of 60 seconds can be fixed with editing your php.ini file and adjusting the "max_execution_time = " variable.

Secondly if the systems is very slow you should check your cache settings in the site.ini (your override file).

Section only loops once. However, for each loop you do two print of an producer names if various conditions are set. Furthermore you should decide on either limiting the producers to show either in the fetch or the looping of the fetched objects.

Cheers
Tore

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu