Announcement

Collapse
No announcement yet.

Replacement for Toolkit Counter Function

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Replacement for Toolkit Counter Function

    I'm sure this is an easy one but I'm not finding a replacement - the Toolkit Function Counter (# 77)

    Code:
    <mvt:item name="toolkit" param="counter|current_nbr|g.offset" />
    
    <mvt:foreach iterator="product" array="products">
    
    <mvt:item name="toolkit" param="counter|current_nbr" />
    &mvte:global:current_nbr;
    
    <mvt:foreach>
    And would it only work with products (if it was placed in a different foreach loop)?
    Leslie Kirk
    Miva Certified Developer
    Miva Merchant Specialist since 1997
    Previously of Webs Your Way
    (aka Leslie Nord leslienord)

    Email me: [email protected]
    www.lesliekirk.com

    Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

  • I think I may have my own answer

    https://docs.miva.com/template-language/while

    Code:
     
    <mvt:assign name="l.my_value" value="10" />
    <mvt:assign name="l.settings:counter" value="0" />
    <mvt:while expr="l.settings:counter LE l.my_value">
    The value of counter is: &mvt:counter; <br>
    <mvt:assign name="l.settings:counter" value="l.settings:counter + 1" />
    </mvt:while>
    ​​​​​​
    Leslie Kirk
    Miva Certified Developer
    Miva Merchant Specialist since 1997
    Previously of Webs Your Way
    (aka Leslie Nord leslienord)

    Email me: [email protected]
    www.lesliekirk.com

    Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

    Comment


    • yay Leslie
      Colin Puttick
      I solemnly swear that I am up to no good...

      Comment


      • I'd strongly recommend adding a test that the value set for my_value is reasonable before beginning such code. We regularly see these types of loops take sites down because some variable is not tested and an infinite, or inappropriately long, loop results.
        David Hubbard
        CIO
        Miva
        [email protected]
        http://www.miva.com

        Comment


        • Originally posted by ILoveHostasaurus View Post
          I'd strongly recommend adding a test that the value set for my_value is reasonable before beginning such code. We regularly see these types of loops take sites down because some variable is not tested and an infinite, or inappropriately long, loop results.
          Ummm...okay....that would help to explain the results I saw when I tried to use what I tried. I had made some "assumptions" on the "value". I had originally used 99 thinking it would automatically adjust to what was needed. Instead, it literally spit out 99 results.
          Leslie Kirk
          Miva Certified Developer
          Miva Merchant Specialist since 1997
          Previously of Webs Your Way
          (aka Leslie Nord leslienord)

          Email me: [email protected]
          www.lesliekirk.com

          Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

          Comment

          Working...
          X

          This website uses cookies to identify visitors, track visitors to our website, store login session information and to remember your user preferences. By continuing to use this site you agree to our use of cookies. Learn More.

          This website uses cookies. By continuing to use this site you agree to our use of cookies. Learn More.

          Accept