Announcement

Collapse
No announcement yet.

Displaying only Active

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

    Displaying only Active

    This snippet of code posted here https://docs.miva.com/code-samples/subcat does a great job of displaying the sub-categories - too good of a job - as it also displays the inactive categories. How do I display just the active categories?

    Code:
    //load current category data
    
    <mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code( g.Category_Code, 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 )" /> <mvt:foreach iterator="subcat" array="sub_categories"> &mvt:subcat:active; &mvt:subcat:agrpcount; &mvt:subcat:code; &mvt:subcat:disp_order; &mvt:subcat:id; &mvt:subcat:name; &mvt:subcat:parent_id; </mvt:foreach>
    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

    #2
    Try adding an mvt:if that checks for active in the loop and then going to the next record if the item is not active:

    Code:
    <mvt:foreach iterator="subcat" array="sub_categories">
      <mvt:if expr="NOT l.settings:subcat:active">
        <mvt:foreachcontinue />
      </mvt:if>
    &mvt:subcat:active; &mvt:subcat:agrpcount; &mvt:subcat:code; &mvt:subcat:disp_order; &mvt:subcat:id; &mvt:subcat:name; &mvt:subcat:parent_id;
    </mvt:foreach>
    M.A.D.* since 1997

    http://www.scotsscripts.com

    *miva application developers

    Comment


      #3
      Thanks Scot! That's exactly what I needed.

      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


        #4
        You can also use:

        Runtime_Category_Load_Code()

        Which is useful because it lists only categories that should be shown to a user based on availability groups AND active.
        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


          #5
          Follow up question - how do I display the subcat image?
          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


            #6
            Code:
                  <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattitle.mvc'" name="l.success" value="CSSUI_CatTitle_Load(l.settings:subcat:id, l.settings:subcat:cat_title)" />
            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
              Originally posted by Bruce - PhosphorMedia View Post
              Code:
              <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattitle.mvc'" name="l.success" value="CSSUI_CatTitle_Load(l.settings:subcat:id, l.settings:subcat:cat_title)" />
              That would work IF the site were CSSUI...
              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


                #8
                oh, try replacing cssui with mmui (not tested, been awhile since i've worked on an mmui).
                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
                  Originally posted by Bruce - PhosphorMedia View Post
                  oh, try replacing cssui with mmui (not tested, been a while since i've worked on an mmui).
                  Thanks, Bruce, that got it. So those of you out there that still have MMUI stores here ya go (make sure you put it inside the foreach loop):

                  Code:
                  <mvt:do file="g.Module_Root $ '/modules/component/cmp-mmui-cattitle.mvc'" name="l.success" value="MMUI_CatTitle_Load(l.settings:subcat:id, l.settings:subcat:cat_title)" />
                  <img src="&mvt:subcat:cat_title:image;" alt="&mvt:subcat:name;">
                  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

                  Working...
                  X