Announcement

Collapse
No announcement yet.

Displaying Custom Field Description under SubCategories?

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

    Displaying Custom Field Description under SubCategories?

    I don't know why this is so impossible to do, but can someone please tell me how I can display my custom field descriptions for my subcategories, which are listed at the top of my CTGY pages? I've looked everywhere, tried every combination of code I can find. Does no one else but me need actual words under their subcategories?
    Last edited by bshaf; 03-12-20, 03:25 AM.

    #2
    Are you trying to use a custom category field?
    Matt Zimmermann

    Miva Web Developer
    Alchemy Web Development
    https://www.alchemywebdev.com
    Site Development - Maintenance - Consultation

    Miva Certified Developer
    Miva Professional Developer

    https://www.dev4web.net | Twitter

    Comment


      #3
      Yes, I made a custom field under Utilities, Type: Category. I can display this just fine on a main category, but there is nothing about subcategories anywhere.

      Comment


        #4
        The displaying of a custom category field is based on the category code. To load the same information on a subcategory, you would have to pass the parent category code. Can you post the Read Function you are using?
        Matt Zimmermann

        Miva Web Developer
        Alchemy Web Development
        https://www.alchemywebdev.com
        Site Development - Maintenance - Consultation

        Miva Certified Developer
        Miva Professional Developer

        https://www.dev4web.net | Twitter

        Comment


          #5
          I'm just trying to modify this code. I've tried every combination of changing category to sub_category and nothing works.

          Code:
          <mvt:item name="customfields" param="Read_Category_ID(l.settings:category:id, 'category_description', l.settings:category:cf:category_description)" />
          <mvt:if expr="l.settings:category:cf:category_description">
              <div class="clear clearfix"></div>
          <div>&mvt:category:cf:category_description;</div>
          </mvt:if>

          Comment


            #6
            In the case of your code, you are pulling in the category ID. The easiest way to have the same content show on the subcategory as the parent would be to copy/paste the "category_description" information from the parents custom field to the subcategory.
            Matt Zimmermann

            Miva Web Developer
            Alchemy Web Development
            https://www.alchemywebdev.com
            Site Development - Maintenance - Consultation

            Miva Certified Developer
            Miva Professional Developer

            https://www.dev4web.net | Twitter

            Comment


              #7
              I don't want to duplicate the same parent category's description on all of my subcategories. I want each subcategory to display its own description that I wrote. Like the following example:

              GARDENING (CTGY Page, main category)

              FLOWERS (subcategory, listed at top of page)
              All Flowers 10% off $40 or more

              POTS (subcategory, listed at top of page)
              All Pots Buy 2 Get 1 Free

              Comment


                #8
                I can't even pull in the same description if I wanted to. If I copy that code (which was taken from the CTGY Header) to the Content (subcategory_listing) box, nothing at all shows up, no matter what I do.

                Comment


                  #9
                  If a category has the "category_description" custom field populated, it should show when you are on that category regardless if it's a parent or subcategory. You might try modifying your call to this:
                  Code:
                  <mvt:item name="customfields" param="Read_Category_ID(l.settings:category:id, 'category_description', l.settings:category:cf)"/>
                  <mvt:if expr="l.settings:category:cf:category_description">
                      <div class="clear clearfix"></div>
                      <div>&mvt:category:cf:category_description;</div>
                  </mvt:if>
                  Matt Zimmermann

                  Miva Web Developer
                  Alchemy Web Development
                  https://www.alchemywebdev.com
                  Site Development - Maintenance - Consultation

                  Miva Certified Developer
                  Miva Professional Developer

                  https://www.dev4web.net | Twitter

                  Comment


                    #10
                    Are you trying to pull the custom field on the category page for each subcategory or when you are on the subcategorys page?
                    Matt Zimmermann

                    Miva Web Developer
                    Alchemy Web Development
                    https://www.alchemywebdev.com
                    Site Development - Maintenance - Consultation

                    Miva Certified Developer
                    Miva Professional Developer

                    https://www.dev4web.net | Twitter

                    Comment


                      #11
                      I'm not talking about when I'm on a category page for that category. That description is already there by default. I'm talking about subcategories that are *displayed as links* at the top of the CTGY page.

                      Books and Booklets (main Category)

                      SubCategory Links on the same page
                      S.L.A.A. BASIC TEXT
                      (WANT TEXT HERE)
                      RECOVERY BOOKS
                      (WANT TEXT HERE)
                      TOPICAL BOOKLETS
                      (WANT TEXT HERE)
                      JOURNAL FOCUS BOOKLETS
                      (WANT TEXT HERE)

                      Comment


                        #12
                        Ah, in that case, try updating your Content (subcategory_listing) code to this:
                        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:item name="customfields" param="Read_Category_ID(l.settings:sub_category:id, 'category_description', l.settings:sub_category:cf)"/>
                        
                                    <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, 1, 1, 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>
                                        <mvt:if expr="l.settings:sub_category:cf:category_description">
                                            <div>&mvt:sub_category:cf:category_description;</div>
                                        </mvt:if>
                                    </div>
                                </mvt:foreach>
                            </div><!-- end sub-category listings -->
                        </mvt:if>
                        Matt Zimmermann

                        Miva Web Developer
                        Alchemy Web Development
                        https://www.alchemywebdev.com
                        Site Development - Maintenance - Consultation

                        Miva Certified Developer
                        Miva Professional Developer

                        https://www.dev4web.net | Twitter

                        Comment


                          #13
                          Are you trying to pull the custom field on the category page for each subcategory...
                          Yes. The subcategories are listed as links at the top of the parent category's page. It already calls the subcategory title, image, and link, but there is no way to display the subcategory description under each one. Does that clarify?

                          Comment


                            #14
                            Ok, I copied and pasted your code. My custom field is called "ctgy-discounts", so I modified that, but nothing still shows up on the page.

                            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:item name="customfields" param="Read_Category_ID(l.settings:sub_category:id, 'ctgy-discounts', l.settings:sub_category:cf)"/>
                            
                                        <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, 1, 1, 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">
                                                </mvt:if>
                                                &mvt:sub_category:name;
                                            </a>
                                            <mvt:if expr="l.settings:sub_category:cf:ctgy-discounts">
                                                <div>&mvt:sub_category:cf:ctgy-discounts;</div>
                                            </mvt:if>
                                        </div>
                                    </mvt:foreach>
                                </div><!-- end sub-category listings -->
                            </mvt:if>

                            Comment


                              #15
                              The issue you may be having is that you are using a dash in the custom field code. Try changing that to an underscore and see if that corrects the issue.
                              Matt Zimmermann

                              Miva Web Developer
                              Alchemy Web Development
                              https://www.alchemywebdev.com
                              Site Development - Maintenance - Consultation

                              Miva Certified Developer
                              Miva Professional Developer

                              https://www.dev4web.net | Twitter

                              Comment

                              Working...
                              X