Announcement

Collapse
No announcement yet.

Subcategory Images

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

  • Subcategory Images

    Is there an extension or coding solution for showing the image of the first product of a subcategory?

  • There is currently no extension for this functionality. However, you should be able to utilize the code from a ReadyTheme like Levels to get you started on something.
    Matt Zimmermann
    Director of UI/UX Standards and Theme Development
    / Miva, Inc.

    Comment


    • Here's the code I used.

      Code:
      <mvt:foreach array="cattree_categories" iterator="cattree_category">
          <mvt:if expr="l.settings:cattree_category:parent_id EQ l.settings:category:id">
              <mvt:assign name="l.null" value="miva_array_insert(l.settings:subcats, l.settings:cattree_category, -1)" />
          </mvt:if>
      </mvt:foreach>
      
      <mvt:assign name="l.settings:subcat_count" value="miva_array_elements(l.settings:subcats)" />
      <mvt:if expr="l.settings:subcats GT 0">
          <div class="row bg-white main-content-row sub-category-layout">
              <mvt:foreach iterator="sub_category" array="subcats">
                  <mvt:comment><!-- Load First Product From Sub Category & It's resized Main image --></mvt:comment>
                      <mvt:if expr="ISNULL l.settings:sub_category:image AND ISNULL l.settings:category:cf:category_hide_sub_category_images">
                          <mvt:do file="g.Module_Library_DB" name="l.result" value="Runtime_ProductList_Load_Offset_Category( l.settings:sub_category:id, 0, 0, l.settings:sub_category:sub_products:next_offset, l.settings:sub_category:sub_products:list )" />
                          <mvt:assign name="l.settings:sub_category:product" value="l.settings:sub_category:sub_products:list[1]" />
                          <mvt:do file="g.Module_Library_DB" name="l.settings:sub_category:product:image_count" value="ProductImageDataList_Load_Product(l.settings:sub_category:product:id, l.settings:sub_category:product:images)" />
                          <mvt:foreach iterator="image" array="sub_category:product:images">
                              <mvt:if expr="l.settings:image:imagetype:code EQ 'main'">
                                  <mvt:assign name="l.settings:sub_category:product:main_image" value="l.settings:image" />
                                  <mvt:foreachstop/>
                              </mvt:if>
                          </mvt:foreach>
                          <mvt:if expr="l.settings:sub_category:product:main_image:image:id">
                              <mvt:do file="g.Module_Library_DB" name="l.result" value="GeneratedImage_FindOrInsert_Image_Dimensions( l.settings:sub_category:product:main_image:image, '300', '200', l.settings:sub_category:product:main_image:generated )" />
                          </mvt:if>
                          <mvt:if expr="l.settings:sub_category:product:main_image:generated:id">
                              <mvt:assign name="l.settings:sub_category:image" value="l.settings:sub_category:product:main_image:generated:image" />
                          <mvt:elseif expr="l.settings:sub_category:product:main_image:image:id">
                              <mvt:assign name="l.settings:sub_category:image" value="l.settings:sub_category:product:main_image:image:image" />
                          </mvt:if>
                      </mvt:if>
      
                  <div class="column half medium-one-third sub-category uppercase">
                      <a href="&mvt:sub_category:link;" title="&mvt:sub_category:name;">
                          <mvt:if expr="l.settings:sub_category:image AND ISNULL l.settings:category:cf:category_hide_sub_category_images">
                              <img src="&mvt:sub_category:image;" alt="&mvt:sub_category:name;" title="&mvt:sub_category:name;" />
                          </mvt:if>
                          &mvt:sub_category:name;
                      </a>
                  </div>
              </mvt:foreach>
          </div><!-- end sub-category listings -->
      </mvt:if>
      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


      • lesliekirk , I forgot to thank you for posting the code on this. It was very helpful!

        Comment


        • Originally posted by eldon99 View Post
          lesliekirk , I forgot to thank you for posting the code on this. It was very helpful!
          eldon99 you are quite welcome!
          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