loop the object

Author Message

M M

Monday 27 December 2004 6:49:13 am

Hi,

Sorry All solutions you're giving me till now is concerned with the objects that are entered while { loop= integer } not

To understand what i mean try to give a cell a bgcolor or anything to specify it , then when you

<table>
{section name=loop loop=6}
<tr>
<td bgcolor= red>
try it even without fetching to any data from the content
if u use {$:item.name} as an example it won't be displayed but the background will
</td>
</tr>
{/section}
</table>

This will display the row repeated for six times not depending on the object i'm fetching , while the normal way we use is

<table>
{section name=Child loop=fetch('content','list', hash('parent_node_id',69))}
<tr>
<td bgcolor=red> {$:item.name} </td>
</tr>
{/section}

</table>

The previous will display rows depending on the number of children objects even if i use max [needs at least 6 to do what i want] or limit [ which is nearly gives the same result as max]

So what i really need is to merge these 2 cases meaning that i can fetch the data i need from a specific node while setting the no of looping [ due to designing issues]

I hope I could let you understand my point of view

Thanks in advance

Tobias Persson

Monday 27 December 2004 7:14:50 am

I combined your examples above. And some math functions.
I think this might solve your problem.

{let loops=6 countitems=0}

<table>
{section  loop=fetch('content','list', hash('parent_node_id',71, limit, 6))}
{set countitems=fetch('content','list_count', hash('parent_node_id',71))}
<tr>
<td bgcolor=red> {$:item.name} </td>
</tr>
{/section}
</table>

{set loops=$loops|sub($countitems)}

{section $loops|gt(0)}
<table>
{section name=loop loop=$loops}
<tr>
<td bgcolor= red> 
try it even without fetching to any data from the content
</td>
</tr>
{/section}
</table>
{/section}

{/let}

M M

Monday 27 December 2004 9:11:03 am

May be i can't understand what you send to me but to the extent i understood the result that i've seen was 20 rows displayed without fetching to any data

So if you can describe what u mean once more please do

Thanks in advance

Tobias Persson

Monday 27 December 2004 10:02:57 am

Opps. I forgot a 'show' in the section. I also moved some variables into the 'let' . Remember to change the p_node_id to the correct value.

Here is the more correct code:

{let loops=6 countitems=0 p_node_id=93}

<table>
{section  loop=fetch('content','list', hash('parent_node_id',$p_node_id, limit, $loops))}
{set countitems=fetch('content','list_count', hash('parent_node_id',$p_node_id))}
<tr>
<td bgcolor=red> {$:item.name} </td>
</tr>
{/section}
</table>

{set loops=$loops|sub($countitems)}

{section show=$loops|gt(0)}
<table>
{section name=loop loop=$loops}
<tr>
<td bgcolor= red> 
try it even without fetching to any data from the content
</td>
</tr>
{/section}
</table>
{/section}

{/let}

M M

Tuesday 28 December 2004 3:41:06 am

Hello

How are you to day? I hope that everything is fine..

I'm sorry to tell you that there is still a problem .By adding the last code you sent to me, the name of the object didn't appear and the background for the cell appears only twice which means that the loop was done only 2 times

Moreover I don't understand why are you writing the code around two different tables, anyway i need it the loop on only one row in one table not more.

Thanks for your attention

Tobias Persson

Tuesday 28 December 2004 4:14:28 am

Hmmm. That was strange. What version of EZ are you using?
I have tried the code both in 3.4 and 3.5.

The code is pretty simple, so it should work. It works like this:

* fetch all but max 6 objects from $p_node_id.
* fetch the no of objects under $p_node_id (and set variable $countitems to this value)
* loop the objects
* calculate the remaining rows by ($loops = 6 - $countitems)
* If loops > 0 then loop $loops times

And about the two tables. I just copied the code you pasted for them, so thats why they are there. Just remove the </table> and <table> in the middle and you will get it in one table.

M M

Tuesday 28 December 2004 5:03:36 am

Would you please resend to me the code you've tried but applied on only one table including one row and one cell

I don't know may be i wrote it with something missing

Thanks in advance

Tobias Persson

Tuesday 28 December 2004 5:21:40 am

Oki.

{let loops=6 countitems=0 p_node_id=72}

<table>
{section  loop=fetch('content','list', hash('parent_node_id',$p_node_id, limit, $loops))}
{set countitems=fetch('content','list_count', hash('parent_node_id',$p_node_id))}
<tr>
<td bgcolor=red> {$:item.name} </td>
</tr>
{/section}

{set loops=$loops|sub($countitems)}

{section show=$loops|gt(0)}
{section name=loop loop=$loops}
<tr>
<td bgcolor= red> 
try it even without fetching to any data from the content
</td>
</tr>
{/section}

{/section}
</table>
{/let}

I have inserted the code inte 3.5 EZ demo at devel.ezpublish.no

You can see it at the top, right now (will be deleted when ez reset the demo) at: http://devel.ezpublish.no/products/black_box

and the template is over at:
http://admindevel.ezpublish.no/visual/templateedit/design/news/override/templates/full/product.tpl

M M

Tuesday 28 December 2004 8:24:48 am

Wow It works :)))

Thanks so so so much

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 19 2025 14:00:27
Script start
Timing: Jan 19 2025 14:00:27
Module start 'layout'
Timing: Jan 19 2025 14:00:27
Module start 'content'
Timing: Jan 19 2025 14:00:28
Module end 'content'
Timing: Jan 19 2025 14:00:28
Script end

Main resources:

Total runtime1.1913 sec
Peak memory usage4,096.0000 KB
Database Queries74

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0104 590.6719152.6094
Module start 'layout' 0.01040.0036 743.281339.8906
Module start 'content' 0.01391.1762 783.1719573.6406
Module end 'content' 1.19010.0012 1,356.812522.3281
Script end 1.1913  1,379.1406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.2923160.0002
Check MTime0.00130.1052160.0001
Mysql Total
Database connection0.00110.089610.0011
Mysqli_queries1.109793.1445740.0150
Looping result0.00080.0653720.0000
Template Total1.146796.320.5734
Template load0.00190.163020.0010
Template processing1.144896.091520.5724
Template load and register function0.00020.018310.0002
states
state_id_array0.00110.095910.0011
state_identifier_array0.00080.064420.0004
Override
Cache load0.00180.1525740.0000
Sytem overhead
Fetch class attribute can translate value0.00080.064520.0004
Fetch class attribute name0.00050.0455100.0001
XML
Image XML parsing0.00270.225620.0013
class_abstraction
Instantiating content class attribute0.00000.0025130.0000
General
dbfile0.00320.2727160.0002
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
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/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: 38
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs