Announcement

Collapse
No announcement yet.

If statement for Category Custom Fields

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

    If statement for Category Custom Fields

    Hi everyone,

    I am working on a Miva Merchant 5.5 storefront and I can't seem to be able to figure out this if statement, for category custom fields:

    <if there's a/any value in the category custom field>
    do something
    <end if>

    It can be done for product custom fields, with Emporium's Toolkit :

    <mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields :customfieldcode">
    do something
    </mvt:if>

    But it doesn't seem to work the same way for category custom fields.
    Any help would be greatly appreciated.
    James Byrne, (USMC Vet.)
    After Dark Grafx
    "We Work After Dark So You Don't Have To!"
    E-Commerce - Design - Hosting - Printing
    Miva Standard Partner. Get up and running fast!
    http://www.afterdarkgrafx.com :: sales [ at ] afterdarkgrafx.com

    #2
    Re: If statement for Category Custom Fields

    I spent hours trying to get to grips with custom category fields.

    At present, the implementation is clunky, to say the least and that's why you don't see much about them. Things you need to know:

    1. you activate them in the Cattree template, not the CTGY template (check the box)
    2. although the term used to call them is "customfield_names", in fact you call the custom field code

    There is something Monty Pythonesque about this.

    So, if "ss" = your custom category field code and "Shipping Size" was your the custom category field name (with input values of Small, Medium and Large), then this will call the field:

    Code:
    <div>&mvt:cattree_category:customfield_names:customfields:ss;:<span class="bold">&mvt:cattree_category:customfield_values:customfields:ss;</span></div>
    Result: Shipping Size:Medium

    See that specific example.

    I had a headache after figuring this out.
    Last edited by Pete McNamara; 08-31-10, 03:37 PM.

    Comment


      #3
      Re: If statement for Category Custom Fields

      I just remembered two other things you need to know:

      3. You can display a custom category field in the cattree. This would be cool: to have a category short description and display that custom category field in the cattree header (e.g. on a colored background etc.). However, be aware that the custom category field in the cattree remain in the cattree page code for ALL of the top level categories on all of the pages - so they even appear in the source code of the checkout pages (because although it is hidden, the cattree is still in the html source code). This is easily fixed by enclosing your category short description (or whatever you display in the cattree) in a conditional, so it only appears on a category page.

      4. there are no import custom category field modules, as far as I am aware. This means either entering them one by one, through Miva Admin or directly injecting them into the database using a program like phpMyAdmin to import them.
      Last edited by Pete McNamara; 08-31-10, 04:24 PM.

      Comment


        #4
        Re: If statement for Category Custom Fields

        Thank you for your responses Pete, but that wasn't exactly what I was looking for. All I wanted was to figure out the IF Statement, that would call a custom category field's value.
        And after many hours I was able to figure it out, so I'm posting the solution here, for others that may want to achieve the same thing.

        Let's say the custom field category code is "benefit", and the variable that would pass it's value is "benefitvalue".

        Code:
        <mvt:item name="toolkit" param="customcategory|benefitvalue|l.all_settings:category:id|benefit" />
        <mvt:if expr="NOT ISNULL g.benefitvalue">
        If there's a value in the custom category field "benefit", then do something, or you can even show the value of the custom field by using &mvte:global:benefitvalue; .
        </mvt:if>
        Hope this will help others.
        James Byrne, (USMC Vet.)
        After Dark Grafx
        "We Work After Dark So You Don't Have To!"
        E-Commerce - Design - Hosting - Printing
        Miva Standard Partner. Get up and running fast!
        http://www.afterdarkgrafx.com :: sales [ at ] afterdarkgrafx.com

        Comment


          #5
          Re: If statement for Category Custom Fields

          Wow! Thanks James. I also spent several hours trying to solve this one before I finally found your solution on the forum. I think Bill Weiland should just drop your code sample right into the already extensive tech notes for the toolkit. Good of you to share it.
          Bill Dunn
          SunCam, Inc.
          http://www.SunCam.com
          [email protected]

          Comment


            #6
            Re: If statement for Category Custom Fields

            Pete,
            Do you know if the custom category code can only be displayed on CSSUI stores? I was able to enable the custom category field on a CSSUI store the way you mentioned but not an MMUI store.

            Comment


              #7
              Re: If statement for Category Custom Fields

              Don't know about MMUI since we have just elected to develop all stores from here on out with the CSSUI interface then just adjust and change as needed.
              James Byrne, (USMC Vet.)
              After Dark Grafx
              "We Work After Dark So You Don't Have To!"
              E-Commerce - Design - Hosting - Printing
              Miva Standard Partner. Get up and running fast!
              http://www.afterdarkgrafx.com :: sales [ at ] afterdarkgrafx.com

              Comment

              Working...
              X