Jump to content

Loop in tpl file?


jgshier

Recommended Posts

I know you can do a foreach, but is there a for loop ? Like in php ? I need to do this in the template file for images that need to their own id.

$x = 10;

for ($j=1;$j<=$x;$j++) {
echo "something".$j

}

 

Edited by WHMCS ChrisD
Added code into code box
Link to comment
Share on other sites

This is what I have in a normal php file

<?php $x =10; ?>

<script>
    $(document).ready(function(){
        <?php
        for ($j=1;$j<=$x;$j++) {
        echo "
        $('#bigimg-$j').bighover({
            width: 'auto',
            height: '300'
        });";


        }
        ?>
    });
</script>
 

How do I convert that ?

Edited by WHMCS ChrisD
Added code into code box
Link to comment
Share on other sites

Think i got it to work, but is there a better way ?

{literal}
<script>
    $(document).ready(function(){
        {/literal}
        {for $j=1 to $z}
        {literal}$('#bigimg-{/literal}{$j}{literal}').bighover({
                width: '{/literal}{$configMouseOverZoomSizeChannels}{literal}',
                height: 'auto'});{/literal}
        {/for}{literal}
    });
</script>
{/literal}

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated