Announcement

Collapse
No announcement yet.

New Custom Fields - Loop Through & Output Defined Fields

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

    New Custom Fields - Loop Through & Output Defined Fields

    I'm working with some rather large image files that will accompany certain products. The files are hosted remotely, and because of their size, would be a great candidate for playing with the new custom fields setup. However, I seem to be having trouble getting them to output when defining the fields and using a foreach.

    Code:
    <mvt:item name="customfields" param="Read_Product_Code(l.settings:product:code, 'PRODIMG1, PRODIMG2, PRODIMG3, PRODIMG4, PRODIMG5', l.settings:prodimgs)" />
    <mvt:foreach iterator="field" array="prodimgs">
      &mvt:field:value;<br/>
    </mvt:foreach>
    <hr />
    &mvt:prodimgs;
    I've tried numerous things but I just can't seem to get it to work in this fashion. 'prodimgs' has data and outputs with &mvt:prodimgs; but not inside the loop. However, if I remove the comma separated list and leave an empty string, then it will loop through and display every custom field attached to the product.

    I have been able to load this in other much longer ways, but this shouldn't require 20 lines to accomplish when 6 will do. Since this won't apply to some products and others won't necessarily have five images, the idea is to check 'prodimgs' for data and then let it loop through and display what is there.

    I thought at first something was wrong with my list of codes but then I should get no output at all so I'm rather confused. Any help you can offer would be appreciated.

    Thanks,
    Tim

    #2
    Re: New Custom Fields - Loop Through &amp; Output Defined Fields

    Hi Tim -

    Conceptually what you have is correct. The problem is that even though the images leverage our custom fields system, they are not accessible like other custom fields. We're going to add a function to access them, however for the time being if you need to use a function like toolkit customimage to loop through them.

    There may also be a way to access them using the new mvt:do. I'll check with development to see if this function exists.
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Re: New Custom Fields - Loop Through &amp; Output Defined Fields

      Hi Brennan,

      I should have clarified that a bit better... The data stored in the custom field is actually just a url to the image which will be the source of an image tag once I get the loop working :)

      Those urls all output to the page with &mvt:prodimgs; call, just not inside the loop (unless I take the list of codes away and get every custom field).

      -Tim

      Comment


        #4
        Re: New Custom Fields - Loop Through &amp; Output Defined Fields

        Thanks for the clarification.

        Then what you're trying to do should work. I believe if you want to return an array you need to use the empty string '' for the field list. When you have a comma separated list like that it saves them as individual variables.

        &mvt:prodimgs:PRODIMG1;
        &mvt:prodimgs:
        PRODIMG2;
        Brennan Heyde
        VP Product
        Miva, Inc.
        [email protected]
        https://www.miva.com

        Comment

        Working...
        X