Announcement

Collapse
No announcement yet.

Displaying Custom Field Description under SubCategories?

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

    #16
    Hi Matt,

    It works! I would have played with this for weeks and not figured it out. The problem was two things, three if you count the fact that I was stuck in the first place. The underscore (thank you) was an issue, and the code was missing the following on line 11:

    Code:
    <mvt:item name="customfields" param="Read_Category_ID(l.settings:sub_category:id, 'ctgy_discounts', l.settings:sub_category:cf:ctgy_discounts)"/>
    So for those of us looking to add a description below the subcategory links on a parent category's page, here it is.
    1. Create a Custom Category Field under Utilities, call it whatever you want, but don't use a dash.
    2. Make sure you have the items "customfields" and "subcategory_listing" enabled.
    3. Copy the code below and overwrite the Content (subcategory_listing) box in your CTGY page.
    4. Change the code to rename the Custom Category Field to the name you chose in the 4 places in bold.
    5. Enter some content in the Custom Field you made under your subcategories

    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:ctgy_discounts)"/>
    
                <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:ctgy_discounts">
                        <div style="text-transform: none;">&mvt:sub_category:cf:ctgy_discounts;</div>
                    </mvt:if>
                </div>  
            </mvt:foreach>
        </div><!-- end sub-category listings -->
    </mvt:if>
    Thank you so much for helping me,
    Beth

    Comment

    Working...
    X