Forums / Setup & design / nested {foreach} and {delimiter}

nested {foreach} and {delimiter}

Author Message

Softriva .com

Wednesday 21 February 2007 6:23:50 am

Dears,

I noticed that the {delimiter} does not work in nested {foreach} is there a system limitations

{def $gnode_id=$node.node_id}
{def $gMenus=fetch(content,list, hash('parent_node_id', 59,'sort_by',array( 'priority', true() ))) $gChildern=false()}

<table>
  <tbody>
   <tr>
     {foreach $gMenus as $gMenu}
      <td>
	<table>
	  <thead>
		<tr><th>{$gMenu.name|wash}</th></tr>
          </thead>
	  <tbody>
	    <tr>
              <td>
               {set $gChildern=fetch(content,list, hash('parent_node_id', $gMenu.node_id,'sort_by',array( 'priority', true() )))}
 	       <ul>
               {foreach $gChildern as $child}
                 <li><a href={$child.url_alias|ezurl}>{$child.name|wash}</a></li>
               {/foreach}
	       </ul>
              </td>
            </tr>
          </tbody>
	</table>
        </td>
	{delimiter modulo=2}
    </tr>
    <tr>
    {/delimiter}
    {/foreach}
    </tr>
  </tbody>
</table>

Claudia Kosny

Wednesday 21 February 2007 7:46:18 am

Hi OOzy

This would be easier if you would have posted an example of what you expected and what you actually received...
Using delimiter in foreach works fine for me:

{def $array1 = array(1,2,3,4)
     $array2 = array('a','b','c','d')}
{foreach $array1 as $value1}
<br />
 {$value1} : <br />
 {foreach $array2 as $value2}
  {$value2}
 {/foreach}
{delimiter modulo=2}
  delim for array1
{/delimiter}
<br />
{/foreach}  

produces

1 :
a b c d

2 :
a b c d
delim for array1
3 :
a b c d

4 :
a b c d 

which is exactly what I would expect.

Claudia

Softriva .com

Thursday 22 February 2007 11:52:16 pm

hmmmm

Claudia,

your code produces


1 :
a b c d

2 :
a b c d

3 :
a b c d

4 :
a b c d

I am running 3.8.6.
This is weird.

André R.

Friday 23 February 2007 4:20:47 am

Claudia, are you using 3.8.7 or 3.9.1 from svn ?

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Softriva .com

Friday 23 February 2007 9:39:43 am

hmmm

why 3.8.7 or 3.9.1 not 3.9?

Can I use 3.9.1? When will it be released?

Softriva .com

Friday 23 February 2007 10:16:40 am

I have just finished upgrading to 3.9 and it works ok.

Softriva .com

Friday 23 February 2007 10:26:04 am

Now, this is crazy. It don't work any more.

I have seen Claudia output. I have seen this on my site.

1 :
a b c d

2 :
a b c d
delim for array1

3 :
a b c d

4 :
a b c d 

this is crazy

Claudia Kosny

Friday 23 February 2007 11:53:59 am

Hi there

I actually tried on eZ 3.8.3, 3.8.6 and 3.9, but all of them had template compiling set to disabled (as they are my local development installations). If I enable it, it does not work anymore, no matter the system.
As I never have used the delimiter (apart from the testing for OOzy), I did not realise that this before. I assume this has been fixed in the versions Andre was mentioning, but I have not tried it.

Claudia

eZ debug

Timing: Jan 18 2025 20:58:07
Script start
Timing: Jan 18 2025 20:58:07
Module start 'content'
Timing: Jan 18 2025 20:58:07
Module end 'content'
Timing: Jan 18 2025 20:58:07
Script end

Main resources:

Total runtime0.2045 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0079 587.7109180.8359
Module start 'content' 0.00790.0172 768.5469102.0078
Module end 'content' 0.02510.1792 870.5547530.8281
Script end 0.2044  1,401.3828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00391.8849200.0002
Check MTime0.00150.7197200.0001
Mysql Total
Database connection0.00120.569210.0012
Mysqli_queries0.135166.08111410.0010
Looping result0.00180.87821390.0000
Template Total0.178787.410.1787
Template load0.00120.596210.0012
Template processing0.177586.803610.1775
Override
Cache load0.00080.386310.0008
Sytem overhead
Fetch class attribute can translate value0.00080.411310.0008
XML
Image XML parsing0.00030.132010.0003
General
dbfile0.01567.6528200.0008
String conversion0.00000.003430.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs