Announcement

Collapse
No announcement yet.

Custom Sub-Category Layout

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

    Custom Sub-Category Layout

    I have started to add some images to our website for sub-categories. It works fine.
    Example here: https://www.designquest.biz/copeland-bedrooms.html

    However, I am trying to customize the sub-category layout for the "Brands" page of our website to not display the sub-category name and my elementary understanding of Miva code is not helping. I am looking for some help.

    Brands Page - I would like only the logo image to show: https://www.designquest.biz/brands.html

    I have modified the sub-category_listing on the CTGY page as follows. Obviously not working. Am I even on track?

    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:category:id NE 'Brands') AND (l.settings:subcats GT 0)">
    <div class="row bg-white bottom-shadow main-content-row sub-category-layout">
    <mvt:foreach iterator="sub_category" array="subcats">
    <mvt:if expr="l.settings:sub_category:image">
    <div class="column half medium-one-third large-one-third sub-category uppercase">
    <a href="&mvt:sub_category:link;" title="&mvt:sub_category:name;">
    <img src="&mvt:sub_category:image;" alt="&mvt:sub_category:name;" title="&mvt:sub_category:name;" />
    <center>&mvt:sub_category:name;</center>
    
    </a>
    </div>
    
    <mvt:else>
    <div class="column half medium-one-third sub-category uppercase">
    <a href="&mvt:sub_category:link;" title="&mvt:sub_category:name;" class="bold">&mvt:sub_category:name;</a>
    </div>
    </mvt:if>
    </mvt:foreach>
    </div>
    <mvt:else>
    <div class="row bg-white bottom-shadow main-content-row sub-category-layout">
    <mvt:foreach iterator="sub_category" array="subcats">
    <mvt:if expr="l.settings:sub_category:image">
    <div class="column half medium-one-third large-one-third sub-category uppercase">
    <a href="&mvt:sub_category:link;" >
    <img src="&mvt:sub_category:image;" />
    </a>
    </div>
    
    <mvt:else>
    <div class="column half medium-one-third sub-category uppercase">
    <a href="&mvt:sub_category:link;" title="&mvt:sub_category:name;" class="bold">&mvt:sub_category:name;</a>
    </div>
    </mvt:if>
    </mvt:foreach>
    </div>
    </mvt:if>
    Katie Sorensen
    Design Quest Furniture

    http://www.designquest.biz

    #2
    Try 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="(tolower(l.settings:category:code) NE 'brands') AND (l.settings:subcats GT 0)">
        <div class="row bg-white bottom-shadow main-content-row sub-category-layout">
            <mvt:foreach iterator="sub_category" array="subcats">
                <mvt:if expr="l.settings:sub_category:image">
                    <div class="column half medium-one-third large-one-third sub-category uppercase">
                        <a href="&mvt:sub_category:link;" title="&mvt:sub_category:name;">
                            <img src="&mvt:sub_category:image;" alt="&mvt:sub_category:name;" title="&mvt:sub_category:name;" />
                            <center>&mvt:sub_category:name;</center>
                        </a>
                    </div>
                <mvt:else>
                    <div class="column half medium-one-third sub-category uppercase">
                        <a href="&mvt:sub_category:link;" title="&mvt:sub_category:name;" class="bold">&mvt:sub_category:name;</a>
                    </div>
                </mvt:if>
            </mvt:foreach>
        </div>
    <mvt:else>
        <div class="row bg-white bottom-shadow main-content-row sub-category-layout">
            <mvt:foreach iterator="sub_category" array="subcats">
                <mvt:if expr="l.settings:sub_category:image">
                    <div class="column half medium-one-third large-one-third sub-category uppercase">
                        <a href="&mvt:sub_category:link;" >
                            <img src="&mvt:sub_category:image;" />
                        </a>
                    </div>
    
                <mvt:else>
                    <div class="column half medium-one-third sub-category uppercase">
                        <a href="&mvt:sub_category:link;" title="&mvt:sub_category:name;" class="bold">&mvt:sub_category:name;</a>
                    </div>
                </mvt:if>
            </mvt:foreach>
        </div>
    </mvt:if>

    Comment


      #3
      It works perfectly! Thank you so much, Leanne. I do so appreciate the help.

      For educational purposes: Can you tell me what the "tolower" accomplishes? Also, you replaced "id" with "Code" here. What is difference? Thanks again.
      (tolower(l.settings:category:code)
      Last edited by d2d2d2; 02-19-19, 07:43 AM. Reason: edited to add question about code.
      Katie Sorensen
      Design Quest Furniture

      http://www.designquest.biz

      Comment


        #4
        Glad it worked for you :)

        Using tolower will convert the code/name/image file/whatever you put in the parentheses to all lowercase. It helps avoid errors due to mismatches in case.

        I replaced "id" with "code" because the category id is a numeric value assigned in the database and isn't something you necessarily know without checking it, whereas the category code is assigned by you in the admin, and is a known value. Your code was failing because you were trying to match the category's id (numerical) to the category's code "Brands" (text).

        Comment


          #5
          That last info on code/id was so informative. Thanks again :)
          Katie Sorensen
          Design Quest Furniture

          http://www.designquest.biz

          Comment


            #6
            Also, using IDs in place of CODES is a little bit faster, since Miva has to use the Code to look up the ID anyway. So, when using functions that come in ID & Code flavors best to use ID if available. And, as Leanne points out, IDs isolate you from issues where someone changes the Code in the admin. (If you change the code of a product or category, the ID remains the same.)
            Bruce Golub
            Phosphor Media - "Your Success is our Business"

            Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
            phosphormedia.com

            Comment


              #7
              Well, that brings up the issue of where to locate specific category ID's? What you are saying, Bruce, is that I could keep the (l.settings:category:id NE 'Brands'), but the 'Brands' would be replaced with the specific category ID? However, I can't seem to locate where one finds the ID for a specific category?

              This is all very educational. Thanks to you and Leanne!
              Katie Sorensen
              Design Quest Furniture

              http://www.designquest.biz

              Comment


                #8
                Yea that's a bit of a downside as the IDs are generally not displayed. Just add <!-- Cat ID: &mvt:category:id; --> to your category template, and then view the source of the Brands category page. Alternately, if installed (and it should be) use the "Token List" tool in the admin to look it up. The Token List can be found under Utilities (its installed by default but not activated). Once activated, you can navigate to your category template, then in upper right corner of the admin under the More button, select Token List. Then add Brand in the "Category: " filter box at the top right.
                Bruce Golub
                Phosphor Media - "Your Success is our Business"

                Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                phosphormedia.com

                Comment


                  #9
                  I tried both methods - just for the learning of it. Token List was installed and activated. Thanks for pointing me toward another aspect of MM that I had previously ignored. Always so much to take in - but interesting! Again, I appreciate the help and patience :)
                  Katie Sorensen
                  Design Quest Furniture

                  http://www.designquest.biz

                  Comment

                  Working...
                  X