replacing toolkit call for category title image outside of the cattree

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kayakbabe
    Mega Mivite




    • Jun 2008
    • 1520

    #1

    replacing toolkit call for category title image outside of the cattree

    I found the wonderful new code that shows how to get all the subcategories belonging to a parent category code.
    I switched from tool belt to using this and it shaved off execution time for this part of my code from .054 to .022

    <mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code('_blank1', l.settings:current_category )" />
    <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Parent( l.settings:current_category:id, l.settings:sub_categories )" />

    And I found info about

    <mvt:item name="customfields" param="Read_Category_Code(l.settings:subcat:code,' image_title', l.settings:customfields )" />

    but it seems odd to me that the function doesn't get the category title image.. It isn't the category tree image.. so.. why doesn't it get the category title?
    I read several times in the forum that the title image and tree image are only called while inside the cattree.
    Seems to me the category title image would be useful in LOTS of places and should be accessible outside of the cattree.

    I found that I could get to the cat title image using toolkit.

    <mvt:item name="toolkit" param="cattreeimage|subcatImage|l.all_settings:sub _category:code" />

    However, I'd like to completely replace the following toolkit script with builtin if possible.
    How can this be done?
    Last edited by kayakbabe; 09-30-16, 02:17 AM.
  • Brennan
    Super Moderator









    • Jun 2009
    • 3481

    #2
    There are separate calls to get the category tree image and category title image.

    Here is how you can load them natively:
    Code:
    <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattree.mvc'" name="l.success" value="CSSUI_CatTree_Load(cat_id, l.settings:cattree )" />
    &mvt:cattree:image;
       
     <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattitle.mvc'" name="l.success" value="CSSUI_CatTitle_Load(cat_id, l.settings:cattitle)" />
    &mvt:cattitle:image;
    In both cases you need to pass in the correct category id as the first parameter.
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment

    • kayakbabe
      Mega Mivite




      • Jun 2008
      • 1520

      #3
      OMG! Perfect! That took the original trace timing from .05 down to .01!
      That is incentive to modernize all the old code in our store. Thank you!

      It will be even faster once I remove the tool belt trace command wrapping it.

      Comment

      • mikel
        Mivite


        • Jun 2006
        • 127

        #4
        Originally posted by kayakbabe View Post
        I found the wonderful new code that shows how to get all the subcategories belonging to a parent category code.
        I switched from tool belt to using this and it shaved off execution time for this part of my code from .054 to .022

        <mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code('_blank1', l.settings:current_category )" />
        <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Parent( l.settings:current_category:id, l.settings:sub_categories )" />
        Would this work in the Category Tree Template of the Levels Ready Theme for limiting the cat-tree on the left to just the active parent cat and its subcats? Levels is already doing what I want it to do with the active parent cat and sub cats, I just don't want the listing of other (non-active) parent cats to show. Been pulling my hair out on this one.

        Comment

        • kayakbabe
          Mega Mivite




          • Jun 2008
          • 1520

          #5
          couldn't you wrap an if statement around what you have already in the category tree template? I'm thinking logic like

          if category is active
          html code
          end if

          Comment

          • mikel
            Mivite


            • Jun 2006
            • 127

            #6
            Not so simple. One issue with having it list only the active category is that when on a Page outside of a category (like an FAQ or Shipping and Returns page) the category tree disappears because it is not in a category any longer. So I need to resolve that issue as well which may mean killing the category tree from the pages and replacing it with something static or have it show them all at that point.

            Comment

            • kayakbabe
              Mega Mivite




              • Jun 2008
              • 1520

              #7
              Mikel, it sounds like your cattree is working exactly how you defined it. You said, "I just don't want the listing of other (non-active) parent cats to show". There isn't a "parent" category on non category pages.
              so on the non category pages, you are going to have to define the specific category variable you want to be the one that shows on those non category pages.
              there is a global category variable and you are going to have to do something in your cattree header like...

              if page code is not CTGY
              then set category code to xxxxxxx
              end if

              if you want it to be the same on all your non category pages, you could set the default category in the store global header instead. but make sure you wrap it in an if statement to make sure that is not a category page.

              Comment

              • mikel
                Mivite


                • Jun 2006
                • 127

                #8
                Cat tree is working great except on Pages but I think I'm going to use URI Management to tack the following onto the back end of any of the Pages urls.
                &Category_Code=&mvta:global:Category_Code;
                That should list the category code they're coming from in the url and give me the left nav category I want. The only issue will be if they're coming directly from elsewhere or directly from the SFNT page in which case I can put some kind of static nav there.

                Comment

                • lesliekirk
                  Super Moderator











                  • Aug 2008
                  • 9290

                  #9
                  Originally posted by Brennan View Post
                  There are separate calls to get the category tree image and category title image.

                  Here is how you can load them natively:
                  Code:
                  <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattree.mvc'" name="l.success" value="CSSUI_CatTree_Load(cat_id, l.settings:cattree )" />
                  &mvt:cattree:image;
                  
                  <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattitle.mvc'" name="l.success" value="CSSUI_CatTitle_Load(cat_id, l.settings:cattitle)" />
                  &mvt:cattitle:image;
                  In both cases you need to pass in the correct category id as the first parameter.
                  I'm wanting to add the category tree image to the subcategories_listings for the CTGY 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 OR l.settings:category_listing:products_on_page_count GT 1">
                      <hr class="border--secondary h-nm">
                  
                          <mvt:if expr="l.settings:subcats GT 0">
                              <section style="padding: 2.625rem 0.75rem; text-align:center; width: 60%; margin: 0 auto;">
                              <nav class="cmp-subcategories inline-list secondary-font">
                                  <ul>
                                      <mvt:foreach iterator="sub_category" array="subcats">
                                          <li>
                                              <a href="&mvte:sub_category:link;">&mvte:sub_category:name;</a>
                                          </li>
                                      </mvt:foreach>
                                  </ul>
                              </nav>
                                  </section>
                              <!-- end .cmp-subcategories -->
                          </mvt:if> 
                      <!-- end .cmp-subcategories-filtering -->
                  </mvt:if>
                  Can I use this?

                  Code:
                  <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattree.mvc'" name="l.success" value="CSSUI_CatTree_Load(cat_id, l.settings:cattree )" />
                  If so, where in the code should I place it. My attempts have been "fatal".
                  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: X | Facebook | Pinterest

                  Comment

                  • Bruce - PhosphorMedia
                    Developer Partner











                    • Mar 2006
                    • 11256

                    #10
                    I always put things like this right AFTER the <foreach> regardless of where they are used inside the loop;

                    Code:
                    <mvt:foreach iterator="sub_category" array="subcats">
                    <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattree.mvc'" name="l.success" value="CSSUI_CatTree_Load(l.settings:sub_category:id, l.settings:cattree:image )" />
                    But first check the l.settings:sub_category:id value...not positive that's what it is in that loop.
                    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

                    Working...
                    X