Forums / Setup & design / recursion in template possible?

recursion in template possible?

Author Message

Michael D.

Wednesday 12 October 2005 2:17:15 am

Hello there.

I wonder if recursion is/will be possible within a template.

What I tried as a test was:
<i>test.tpl</i>

{default test=0}
    {$test}+
    {section show=$test | lt(5)}
        {include uri="design:test.tpl" test=$test|inc}
        {set test=$test|dec}
    {/section}
    {$test}-
{/default}

output: 0+ 1+ 2+ 3+ 4+ 5+ 5- 4- 3- 3- 3- 3-

I would expect it to work like this:
<i>test2.tpl</i>

{default test2=0}
    {*0*}
    {$test2}+
    {set test2=$test2|inc}
        {*1*}    
        {$test2}+
        {set test2=$test2|inc}
            {*2*}    
            {$test2}+
            {set test2=$test2|inc}
                {*3*}    
                {$test2}+
                {set test2=$test2|inc}
                    {*4*}    
                    {$test2}+
                    {set test2=$test2|inc}
                        {*5*}    
                        {$test2}+
                        {*backstepping begins*}
                        {$test2}-
                    {set test2=$test2|dec}
                    {$test2}-
                {set test2=$test2|dec}
                {$test2}-
            {set test2=$test2|dec}
            {$test2}-
        {set test2=$test2|dec}
        {$test2}-
    {set test2=$test2|dec}
    {$test2}-
{/default}

output: 0+ 1+ 2+ 3+ 4+ 5+ 5- 4- 3- 2- 1- 0-

The second template is my idea of the transition from recursive to iterative but the recursion seems to work very different.

Is there a chance this behaviour will be changed in the future or am I hoping for the impossible (due to the nature of the internal handling of this)?

Thanks, Michael

Alexandre Abric

Wednesday 12 October 2005 6:53:48 am

Hi,

That's strange : I used the same template with eZ Publish 3.6.1 and I got the expected result.

0+ 1+ 2+ 3+ 4+ 5+ 5- 4- 3- 2- 1- 0-

What version did you use ?

Michael D.

Wednesday 12 October 2005 7:16:17 am

Sorry, I forgot to mention: It's eZ publish 3.6.1 svn rev. 12063.

I'm including it in the pagelayout.tpl, could that make a difference?
It's the first include and there is no other var named "test" in the pagelayout.tpl.

Settings are:
TemplateCompile=enabled
ViewCaching=disabled
TemplateCache=enabled

The rest is default or not listed because I don't think they are important in this matter. If some are, please let me know and I'll post them here.

Alexandre Abric

Monday 17 October 2005 5:27:20 am

I think there should be a difference if you included the code in the pagelayout.tpl

For the test, I created a folder called "TEST RECURSION", created an override for the full view of the node, and added the code you provided.

Michael D.

Monday 17 October 2005 6:08:32 am

I tried your way with the node override but I'm still getting the same (undesirable) result.

I'll try to make a clean ez 3.6 install and test it there as well as on another system.

Hopefully this will bring me closer to the solution.
Since your response indicates this, there has to be a way to make it work.

eZ debug

Timing: Jan 18 2025 22:19:20
Script start
Timing: Jan 18 2025 22:19:20
Module start 'content'
Timing: Jan 18 2025 22:19:20
Module end 'content'
Timing: Jan 18 2025 22:19:20
Script end

Main resources:

Total runtime0.1759 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.7266180.8359
Module start 'content' 0.00790.0055 768.562597.8828
Module end 'content' 0.01340.1624 866.4453527.8047
Script end 0.1757  1,394.2500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00372.0907200.0002
Check MTime0.00140.7829200.0001
Mysql Total
Database connection0.00070.404310.0007
Mysqli_queries0.126171.69451410.0009
Looping result0.00150.83201390.0000
Template Total0.162092.110.1620
Template load0.00100.553910.0010
Template processing0.161091.535010.1610
Override
Cache load0.00060.359410.0006
Sytem overhead
Fetch class attribute can translate value0.00090.519810.0009
XML
Image XML parsing0.00030.180810.0003
General
dbfile0.00341.9447200.0002
String conversion0.00000.002230.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