Announcement

Collapse
No announcement yet.

variable within a variable

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

  • variable within a variable

    Is it possible to use a variable within a variable?

    For instance, in this token, &mvt:subcats[18]:code; I would like to use a variable for the number (in this case 18).

    So, is it possible to have it function like: &mvt:subcats[number]:code;

    Using toolkit, I created a random number variable and tried using it like this:
    <mvt:item name="toolkit" param="vrandom|number|l.all_settings:subcat_count" />
    &mvt:subcats[number]:code;

    However, no go.

    Is there a way to do this?

    Thanks.







  • When using Tool Kit in this way, 'number' is a global variable. Try this as your token:
    Code:
    &mvt:subcats[&mvt:global:number;]:code;
    Matt Zimmermann
    Director of UI/UX Standards and Theme Development
    / Miva, Inc.

    Comment


    • Hi Matt,

      Thank you for the response.
      Yes, I had already tried that. Here is the error message:
      Fatal error in mm5/5.00/templates/s01/c51-footer.mvc @ [00000002:0000005c]: modules/component/cmp-cssui-pchdft.mv: Line 4: Array index must be positive integer

      Comment


      • Check to make sure that &mvt:global:number; is outputting. If it isn't, you may need to check the variable being used to generate the random number.
        Matt Zimmermann
        Director of UI/UX Standards and Theme Development
        / Miva, Inc.

        Comment


        • It is outputting.
          &mvt:global:number; does show a number value.

          Comment


          • Can you post the function you are passing the global number into?
            Matt Zimmermann
            Director of UI/UX Standards and Theme Development
            / Miva, Inc.

            Comment


            • <mvt:item name="toolkit" param="vrandom|number|l.all_settings:subcat_count" />
              &mvt:global:number;
              <br>
              &mvt:subcats[&mvt:global:number;]:code;

              Comment


              • Are you using this within a Tool Kit function or is it just for displaying the particular code?
                Matt Zimmermann
                Director of UI/UX Standards and Theme Development
                / Miva, Inc.

                Comment


                • I am using it in a ReadyTheme Product Listing (carousel).
                  I have also tried it on the footer of a category page.
                  In both cases I do get a value for &mvt:global:number;

                  Comment


                  • It looks like, at this time, without using something like Tool Belt, Miva will not render a variable within a variable like you are trying to do. You can see an example of how to use the assign function in Tool Belt here, see example 4 http://www.pcinet.com/p/toolbelt_docs.html#Assign
                    Matt Zimmermann
                    Director of UI/UX Standards and Theme Development
                    / Miva, Inc.

                    Comment


                    • What if you tried something like this?

                      Code:
                      <mvt:eval expr="l.settings:subcats[g.number]:code" />
                      David Carver
                      Miva, Inc. | Software Developer

                      Comment


                      • Thanks dcarver,

                        Tried it but the same error.

                        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