Announcement

Collapse
No announcement yet.

Loop Through Custom Field With Comma Separated Values

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

  • Loop Through Custom Field With Comma Separated Values

    Loop Through Custom Field With Comma Separated Values...

    We have a client that did this on their current site. We're trying to implement on their development site.

    I can check to see if the custom field has a value, and that comes back true when it's populated.

    I'm trying to loop through the values as was done on the current site but my loop fails.

    Apparently, it uses the Emporium Plus Tool Kit module what has been added and turned on.

    This is the current site's code which I tried to put into my template first. Made some small tweaks but nothing I do works.

    Anyone have any ideas?

    Code:
    <mvt:item name="toolkit" param="vquick|pcount|l.settings:product:cf:alsobought" />
        <mvt:if expr="pcount GT 0">
            <br>
            <table border="0" width="100%">
                <tr>
                    <td align="left" colspan="3">
                        <mvt:item name="fonts" param="hdr_font">
                            <b>Customers Also Bought</b>
                        </mvt:item>
                     </td>
                 </tr>
            <mvt:foreach iterator="quicklist" array="quicklists">
                <tr>
                    <td align="left" valign="top">
                        <mvt:if expr="NOT ISNULL l.settings:quicklist:thumbnail">
                            <img src="&mvt:quicklist:thumbnail;" border="0" width="50" height="50" alt="&mvta:quicklist:name;">
                        <mvt:else>
                            <img src="/mm5/graphics/en-US/admin/blank.gif" border="0" width="50" height="50" alt="&mvta:quicklist:name;">
                        </mvt:if>
                     </td>
                     <td align="left" valign="top">
                         <mvt:item name="fonts" param="body_font">
                             <a href="&mvt:global:sessionurl;Screen=PROD&Product_Code=&mvta:quicklist:code;">
                                 &mvt:quicklist:name;
                             </a>
                          </mvt:item>
                      </td>
                      <td align="left" valign="top">
                          <mvt:item name="fonts" param="body_font">
                              &mvt:quicklist:formatted_price;
                          </mvt:item>
                       </td>
                   </tr>
                </mvt:foreach>
               </table>
    </mvt:if>

  • I haven't used Bill's quicklist but I think something like this would work:

    Code:
    <mvt:item name="customfields" param="Read_Product_Code( 'product_code', 'alsobought', l.settings:customfields:alsobought )" />
    <mvt:if expr="l.settings:customfields:alsobought">
      <mvt:assign name="l.settings:quicklists" value="miva_array_deserialize( l.settings:customfields:alsobought )" />
      <mvt:foreach iterator="quicklist" array="quicklists">
        <mvt:do name="l.return" file="g.Module_Library_DB" value="Runtime_Product_Load_Code( 'l.settings:quicklist', l.settings:product )" />
        <mvt:assign name="l.has_members" value="miva_struct_members( l.settings:product, l.settings:product_members )" />
        <mvt:foreach iterator="product_member" array="product_members">
          &mvt:product_member; : <mvt:eval expr="miva_variable_value( 'l.settings:product:' $ l.settings:product_member )" /><br>
        </mvt:foreach>
      </mvt:foreach>
    </mvt:if>
    Last edited by alphabet; 08-11-18, 12:58 PM. Reason: added output of miva_variable_value of each member
    http://www.alphabetsigns.com/

    Comment


    • You can do this without Toolkit and you're not stuck using a comma (although this example is a comma).

      Once you get the customfield string and qualify it:

      Code:
      <mvt:do file="g.Module_Library_Utilities" name="l.success" value="SplitString(commadelimstring, ',', l.settings:commadelimstringtoarray)" />
      <mvt:foreach iterator="string" array="commadelimstringtoarray">
      ...whatever you need to do here,,,
      </mvt:foreach>
      Scott
      My T-shirt Collection is mostly MivaCon T-shirts!!
      Interactive Design Solutions
      MivaMerchant Business Partner | Certified MivaMerchant Web Developer
      http://www.southbound.com
      Popular Modules and Integrations:
      Product Copy | Wholesale Pricing | AutoBaskets

      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