Announcement

Collapse
No announcement yet.

Display a custom category field

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

    Display a custom category field

    I am trying to display a custom category field from a sub-category, on a category page. Is this possible?

    You can show the sub category NAME buy using &mvt:subcats:name; or CODE by using &mvt:subcats:code; but I can't figure out how to display a custom field value.

    any help would be appreciated.
    Last edited by amecca; 09-28-10, 03:44 PM.
    Alan Mecca
    President
    8:30-5:00 M-Th, 8:30-4:30 F
    T: 800-899-0620
    E: [email protected]
    www.personalizeddoormats.com


    #2
    Re: Display a custom category field

    Emporium Plus Tool Kit:

    94. Use customcategory to insert a custom category field value on the CTGY page template.
    <mvt:item name="toolkit" param="customcategory|cattotal|l.all_settings:cate gory:id|productcount" />
    &mvte:global:cattotal;
    This will check the custom category field "productcount" for the current category and save the value to a variable called "cattotal". You can then mvte the cattotal variable to display it. Note: This function requires use of the Miva Corp built-in custom fields module and that you have created custom category fields. This example is using the custom category field "productcount". That field is automatically created if you run the Products in Category Count under admin > utilities > Emporium Plus Tool Kit. Keep in mind, you cannot use the count feature if your store uses availability groups or your products are hidden when they go out of stock. That is because the feature is run in admin whenever you change products in categories. It remains static until you run it again. In addition to being able to display the count as above, you can assign the custom field productcount to the category tree template and display counts in the tree with:
    <mvt:if expr="NOT ISNULL l.settings:cattree_category:customfield_values:cus tomfields:productcount">
    (&mvt:cattree_category:customfield_values:customfi elds:productcount;)
    </mvt:if>
    <mvt:if expr="NOT ISNULL l.settings:cattree_category:customfield_values:cus tomfields:cathaschild">
    +
    </mvt:if>

    Beginning with Tool Kit version 5.163, you can use the category code instead of the category ID by using the function customcategoryc. Sometimes the code is available and the ID is not. That said, if the ID is available use the customcategory function as it is faster.
    Bill Dunn
    SunCam, Inc.
    http://www.SunCam.com
    [email protected]

    Comment


      #3
      Re: Display a custom category field

      I have been working with that but for some reason it is not pulling the data.

      I have a parent category where you can choose the style. Within that category I would like to be able to show the sizes available within that style. Some are "2x3 only" others are "2x3, 3x5,4x6, etc."

      So in the sub category I set up a custom field called Sizes Available with the code SizesAvailable. And populated that field with the various sizes available.

      I then added this line of code, at the parent level.

      <mvt:item name="toolkit" param="customcategory|sizes|l.all_settings:categor y:id|SizesAvailable" />
      &mvte:global:sizes;</td>

      The toolkit is assigned. I just updated with the latest version of toolkit (although I don't think that matters). To pull the name from the sub category I have to use &mvt:subcats:name; I see nowhere in the code line above where it specifies the subcat, but maybe it is not necessary in that case.
      Alan Mecca
      President
      8:30-5:00 M-Th, 8:30-4:30 F
      T: 800-899-0620
      E: [email protected]
      www.personalizeddoormats.com

      Comment


        #4
        Re: Display a custom category field

        You said, "So in the sub category I set up a custom field called Sizes Available with the code SizesAvailable."

        So the line you use for customcategoryc has to be the category code of the subcategory, not the parent. Do you have an array of sub categories that show the category code?
        Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
        Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
        Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
        Facebook http://www.facebook.com/EmporiumPlus
        Twitter http://twitter.com/emporiumplus

        Comment


          #5
          Re: Display a custom category field

          Not sure I follow. But I did not add any code that specifies an array, unless it is in the code referencing the catman:trail.

          Code:
          <mvt:item name="html_profile" />
          <head>
           <title>&mvt:store:name;: &mvt:category:name;</title>
           <base href="&mvt:global:basehref;">
                  <mvt:item name="prodctgy_meta" param="ctgy" />
           <mvt:item name="head" param="head_tag" />
          </head>
          <mvt:item name="body">
           <mvt:item name="hdft" param="global_header" /> 
           <table border="0" cellpadding="0" cellspacing="0" width="100%">
           <tr><td align="left" valign="top" >
            <mvt:item name="catman" param="trail" />
            <mvt:if expr="NOT ISNULL l.settings:catman:trail">
            <p align="right">
            <mvt:item name="fonts" param="ctgy_font">
            <a href="/merchant2/">
            <u>Products</u></a>
            <mvt:foreach iterator="trail" array="catman:trail">
            <mvt:if expr="pos1 GT 1">
              > 
            <a href="/c/&mvta:trail:code;">
            <u>&mvt:trail:name;</u></a>
            </mvt:if>
            </mvt:foreach>
            </mvt:item>
            </p>
            </mvt:if>
             
            <h1>&mvte:category:name;</h1>
             <p align="justify"><mvt:item name="prod_ctgy_hdft" param="ctgy_header" /></p>
            <mvt:item name="catman" param="subcats" />
            <mvt:if expr="NOT ISNULL l.settings:catman:subcats">
            <table align="center" cellpadding="5" cellspacing="5" width="100%">
            <tr>
            
            <mvt:foreach iterator="subcats" array="catman:subcats">
            <td align="center" width="33%" valign="top">
            <table border=0 cellpadding=0 cellspacing=0>
            <tr>
              <td align="center" valign="top" class="pname"><a href="/c/&mvta:subcats:code;">&mvt:subcats:name;</a><br />
              <mvt:item name="toolkit" param="customcategory|sizes|l.all_settings:category:id|SizesAvailable" />
          &mvte:global:sizes;</td>
            </tr>
            <tr><td align="center" valign="top" style="border:1px solid #005027;">
              <mvt:if expr="NOT ISNULL l.settings:subcats:image">
                <a href="/c/&mvta:subcats:code;"><img src="&mvt:subcats:image;" width="268" height="126" border="0"></a>
                <mvt:else>
               </mvt:if>
              </td>
            </tr>
            </table></td>
            <mvt:if expr = "(pos1 MOD 3 ) EQ 0">
            <tr>
            </mvt:if>
            </mvt:foreach>
            </tr></table>
            </mvt:if>
             
             </td></tr>
           </table>
           <mvt:item name="hdft" param="global_footer" /> 
          </mvt:item>
          </html>
          I am using your category manager if that helps in any way.
          Alan Mecca
          President
          8:30-5:00 M-Th, 8:30-4:30 F
          T: 800-899-0620
          E: [email protected]
          www.personalizeddoormats.com

          Comment


            #6
            Re: Display a custom category field

            Maybe
            <mvt:item name="toolkit" param="customcategoryc|sizes|l.all_settings:subcat s:code|SizesAvailable" />
            Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
            Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
            Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
            Facebook http://www.facebook.com/EmporiumPlus
            Twitter http://twitter.com/emporiumplus

            Comment


              #7
              Re: Display a custom category field

              That did it. Thanks as always.
              Alan Mecca
              President
              8:30-5:00 M-Th, 8:30-4:30 F
              T: 800-899-0620
              E: [email protected]
              www.personalizeddoormats.com

              Comment


                #8
                Re: Display a custom category field

                Hi,

                I have a similar issue.

                I am trying to display the value of a Custom Category field from within an array.
                They array value is set to Category and I'm trying to display the value of the custom field relevent to that category.

                Code:
                <mvt:foreach iterator="Category" array="subcats2"><p>&mvte:Category;</p>
                <mvt:item name="toolkit" param="customcategoryc|Sname|Category|Snippet" />
                <p>&mvt:global:Sname;</p>
                </mvt:foreach>
                This displays the correct Category Codes (&mvte:Category; Outputs correctly) but doesn't get the value of the custom field.
                I think it's to do with the way I reference Category in the tookit function. I've tried g.Category in it's place and that deosn't work either.

                Can any one help please.

                Many Thanks.
                Facewest- UK Adventure sports Equipment
                www.facewest.co.uk

                Comment


                  #9
                  Re: Display a custom category field

                  Not sure exactly what you are using to fire that array, but I would say try something like l.all_settings:Category. If that doesn't work, you may want to use the built-in or any of the available developer mods to list availalbe variables. We have a free one that includes ip based test orders, feel free to reach out to us if you would like a copy.

                  Comment


                    #10
                    Re: Display a custom category field

                    Try the code below. This uses the built in custom fields.

                    Code:
                    <mvt:foreach iterator="Category" array="subcats2">
                        <p>&mvte:Category;</p>
                        <mvt:item name="customfields" param="Read_Category_Code(l.settings:category:code, 'snippet', g.sname)"
                        <p>&mvt:global:sname;</p>
                    </mvt:foreach>
                    Here are the docs on how to use these custom field functions

                    http://www.mivamerchant.com/videos/a...-documentation
                    Last edited by Brennan; 10-02-14, 07:32 AM.
                    Brennan Heyde
                    VP Product
                    Miva, Inc.
                    [email protected]
                    https://www.miva.com

                    Comment


                      #11
                      Re: Display a custom category field

                      Hi,

                      Thanks Brennan, but I think the problem with that code is that the l.setting.Category_code is not working as all I've done is build an array from a text list. At no point is an actual category list being reference.

                      I want to do it this way to get round the case where certain categories can only have 1 parent. Thus if I use a custom field to enter the list of subcats then I can dynamically generate these.


                      Here's the full simplified code.
                      I'm running the code on the CTGY page. For Category "Widgets"
                      The value of the customCat field Subs for the Category "Widgets" is for example: Category1,Category2,Category3
                      This is different to the actual sub cats for that page.


                      Code:
                      <mvt:item name="toolkit" param="vacreate|subcats2|l.all_settings:customcategoryfield:Subs|," />
                      
                      <mvt:foreach iterator="Category" array="subcats2">
                           Category Name: &mvte:Category;<br>
                           <mvt:item name="customfields" param="Read_Category_Code(Category, 'CatSnippet', g.sname)"/>
                           Category custom field snippet value: &mvte:global:sname; <br><br>
                      </mvt:foreach>
                      This Outputs the correct Category names (Eg: Category1,Category2,Category3 etc)
                      But I cannot pull the matching value from the custom category fields.
                      I have both the built in and Sebenza Ultimate Custom Field options.

                      Thanks
                      Facewest- UK Adventure sports Equipment
                      www.facewest.co.uk

                      Comment


                        #12
                        Re: Display a custom category field

                        Based on that info, I would say:
                        l.all_settings:Category (Toolkit custom field function)
                        l.settings:Category (stock Miva Merchant custom field function)

                        This Outputs the correct Category names (Eg: Category1,Category2,Category3 etc)
                        Category names or category codes? If they are category names then Read_Category_Code is not going to fire properly as it is looking for category codes.

                        Comment


                          #13
                          Re: Display a custom category field

                          Hi,

                          OK thanks Brennan, I got it to work.

                          For those interested I think I've got some useful functionality.

                          I've always found a limitation with Miva is the inability to have multiple parent / child relationships in categories.

                          I'd like to have the following working:

                          Parent1
                          SubCat1
                          SubCat2
                          SubCat3
                          SubCat4

                          ParentCategory2
                          SubCat1
                          SubCat2
                          SubCat4
                          SubCat5

                          The only way I could get that to work before was to use the category headers and put the code in there. But this would need updating every-time we changed our template code or updated category information such as snippets or images.

                          Now I can make the Parent1 Category the parent of Subcat1-4

                          I then make ParentCat2 have a custom field value of "Subcat1,Subcat2,Subcat3"

                          Then I use a variant of the code below to build the subcats for Parent2Cat if there is a custom field value 'Subs'.
                          Works a treat. And will save us loads of admin time come template changes.
                          Effectively it's another way to store parent-child relationships that overrides the default miva behaviour.

                          Code:
                          <mvt:item name="toolkit" param="vacreate|subcats2|l.all_settings:customcategoryfield:Subs|," /><mvt:foreach iterator="FakeSubCat" array="subcats2">
                              FakeSubCat:: &mvte:FakeSubCat; 
                              <mvt:item name="customfields" param="Read_Category_Code( l.settings:FakeSubCat, 'CatSnippet', g.test2 )" />
                              <br>Value of Custom Field CatSnippet:: &mvt:global:test2;<br><br>
                          </mvt:foreach>
                          Last edited by Jake Herbert; 10-03-14, 01:15 AM.
                          Facewest- UK Adventure sports Equipment
                          www.facewest.co.uk

                          Comment

                          Working...
                          X