Announcement

Collapse
No announcement yet.

Using Custom Fields on Category Pages

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

    Using Custom Fields on Category Pages

    Scroll to the end for the final solution!

    This first part is blocking me from getting further on the second part.

    First Part

    Steps to Reproduce:
    1. 01.jpg (Custom fields page) - created a custom field
    2. 02.jpg (A Random Category page) - New custom field is showing up on category page as expected.
    3. 03.jpg (Category Display Page CTY)
      1. Expected result: I expected to see my new custom field in this list.
      2. Actual Result: My new custom field is not showing up as an option to add to this template.
    Second Part

    The issue described above is blocking me from further experimentation, but I will continue describing my desired outcome since that may not go as expected either.

    (04.jpg) What I'm basically trying to do is insert some code into the cateogy page if the admin wanted to make it a landing page. Landing pages are usually much simpler, so I will use some CSS to hide elements on the page as well as a little Jquery to add and remove classes. The code you see in my content is more of a proof of concept not actual functional code.

    Then I plan to find the spot on the category display page where I want that CSS and Jquery to appear and post the following code. (At least, I think. Like I said, haven't been able to get here to fiddle with it.)

    Code:
    <mvt:item name="customfields" param="Read_Category_Code( l.settings:category:code, ‘isLandingPage’, g. isLandingPage )" />
    <mvt:if expr="g. isLandingPage EQ 1">
    <mvt:item name="readytheme" param="contentsection( 'isLandingPage' )" />
    </mvt:if>
    Last edited by emilytaege; 04-01-18, 08:17 AM.

    #2
    Did you assign a customfield item to your CTGY page?

    Comment


      #3
      That's what I am getting stuck on for #3 on the first part. Here's a screen shot: https://www.miva.com/forums/filedata...photoid=695269

      When I scroll through that list, I expected to see a "Is Landing Page" custom field in it, but it's not there.

      Ideas?

      Comment


        #4
        The list of custom fields below the Category Product List Layout template are "product" custom fields. Category Custom fields are not automatically populated (not sure why). So you need to add this at the top of the Category Details template:

        Code:
        <mvt:item name="customfields" param="Read_Category_Code( l.settings:category:code, 'your_custom_field_code', l.settings:customcat )" />
        Afterwards you can use:

        l.settings:customcat:your_custom_field_code

        in expressions and

        &mvt:customcat:your_custom_field_code;

        to display the content.

        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
          Thanks very much for your help so far. Here's where I am at:
          1. See Screen Cap - On the custom fields page, I created a custom field
          2. See Screen Cap - On a random category page I verified that the new custom field is showing up on category page as expected. I also checked the box to turn it on.
          3. See Screen Cap - On the content sections page, I created a content section "isLandingPage" and put in a very simple CSS style.
          4. See Screen Cap - On Category Display Page CTY I pasted in a custom cat into the template box at the top.
          5. See Screen Cap - Scrolling down (CTY), I pasted in the following code into the Header field. The placement of this code is important because the css and jquery may have to load at different times based on when the elements load into the browser, and when the jquery fires (but I'll figure that out later). For now, I just have a very simple style in the content section to turn all the links <a> pink. Then I will know the miva script is working.
          Code:
          <mvt:item name="customfields" param="Read_Category_Code( l.settings:category:code, 'isLandingPage', g.isLandingPage )" />
          <mvt:if expr="g.isLandingPage EQ 1">
          <mvt:item name="readytheme" param="contentsection( 'isLandingPage' )" />
          </mvt:if>
          It's not quite working yet though. I'm sure there are problems with my miva script because I really haven't wrapped my head around the syntax. I'm learning slowly. I know you mentioned using what you posted in expressions and displaying content, but I'm afraid I don't know exactly where to put it.
          Attached Files
          Last edited by emilytaege; 03-29-18, 11:36 AM.

          Comment


            #6
            Is the CustomField item (under the Items tag, not the selection box) assigned? Can you do a test before the conditional to validate its correct value? (i.e., <mvt:eval expr="g.isLandingPage"/> ). Also check that the ReadyTheme item is also assigned to the CTGY page.
            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
              I never noticed that "item" area before. The custom field item wasn't assigned, so I just turned it on. I checked the ReadyTheme item too, and that was activated.

              Bruce, you said "Can you do a test before the conditional to validate its correct value? (i.e., <mvt:eval expr="g.isLandingPage"/> )." Can you give me the entire block of code you want me to paste in and also tell me where to paste it? Your instructions sounded like you wanted me to put the code like this See Screen Cap.

              To try something a little different as a test, I put in JUST the content section on the category page and that is working as expected. But I can't get the conditional code working.

              Code:
              <mvt:item name="readytheme" param="contentsection( 'isLandingPage' )" />
              Updating my steps with new information:
              1. See Screen Cap - On the custom fields page, I created a custom field
              2. See Screen Cap - On a random category page I verified that the new custom field is showing up on category page as expected. I also checked the box to turn it on.
              3. See Screen Cap - On the content sections page, I created a content section "isLandingPage" and put in a very simple CSS style.
              4. NEW: See Screen Cap - On Category Display Page CTY I turned on custom fields Item
              5. NEW: [ATTACH]n1593[/ATTACH] - On Category Display Page CTY I verified that the readythemes Item was activated.
              6. See Screen Cap - On Category Display Page CTY I pasted in a custom cat into the template box at the top.
              7. NEW: On Category Display Page CTY I pasted in <mvt:item name="readytheme" param="contentsection( 'isLandingPage' )" /> just after the body tag to see if the content section and the code inside it was working. It works as expected.
              8. See Screen Cap - Scrolling down (CTY), I pasted in the following code into the Header field. The placement of this code is important because the css and jquery may have to load at different times based on when the elements load into the browser, and when the jquery fires (but I'll figure that out later). For now, I just have a very simple style in the content section to turn all the links <a> pink. Then I will know the miva script is working.
              Code:
              <mvt:item name="customfields" param="Read_Category_Code( l.settings:category:code, 'isLandingPage', g.isLandingPage )" />
              <mvt:if expr="g.isLandingPage EQ 1">
              <mvt:item name="readytheme" param="contentsection( 'isLandingPage' )" />
              </mvt:if>
              Last edited by emilytaege; 03-29-18, 03:51 PM.

              Comment


                #8
                your code for testing the conditional is fine. usually i put the eval right before the use of the condition...but that's just me.
                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
                  Well I dunno then. I tried it with the conditional once already and nothing seemed to happen. This is the code I used, and where I placed it. I expected the <a> links to turn pink, but... nothing. No dice. See Screen Cap
                  Last edited by emilytaege; 03-30-18, 04:02 AM.

                  Comment


                    #10
                    Two things:

                    1. Did you actually check off the custom field box for Is Landing Page on the category you are testing?

                    2. In your code further above in the thread you were using g.isLandingPage for your variable, but then in your most recent screenshot you changed it to l.settings:customcat but you're still testing for g.isLandingPage

                    Code:
                     
                     <mvt:item name="customfields" param="Read_Category_Code( l.settings:category:code, 'isLandingPage', l.settings:customcat )" /> <mvt:eval expr="g.isLandingPage" /> <mvt:if expr="g.isLandingPage EQ 1"> <mvt:item name="readytheme" param="contentsection( 'isLandingPage' )" /> </mvt:if>

                    Comment


                      #11
                      Hi Leanne, thanks for your help. To answer your questions

                      1. Yep, I did check the box on the category page. I updated my screen shot to show that. I know it was unchecked before.
                      2. I tried changing the expression from g.isLandingPage to l.isLandingPage, but that doesn't do anything either.

                      I also tried something else that is a little simpler code-wise just to test something out. I changed the custom field to a text field, went over to that category page and dropped the word "test" in it. Then on the CTY display page I tried dropping in &mvt:customcat:isLandingPage; just to see if I could get the word "test" to appear on the page, but that doesn't work either. It's like the template doesn't know to look for the isLandingPage custom field at all. Typically on a product page I'd select it from that scroll box and merge it from the left side to the right side... but it seems like the process is different for a category page, and I think that's where this is getting stuck.

                      Updating my steps with new information: *
                      1. See Screen Cap - On the custom fields page, I created a custom field
                      2. NEW: See Screen Cap - On a random category page I verified that the new custom field is showing up on category page as expected. I also checked the box to turn it on.
                      3. See Screen Cap - On the content sections page, I created a content section "isLandingPage" and put in a very simple CSS style.
                      4. See Screen Cap - On Category Display Page CTY I turned on custom fields Item
                      5. See Screen Cap- On Category Display Page CTY I verified that the readythemes Item was activated.
                      6. See Screen Cap - On Category Display Page CTY I pasted in a custom cat into the template box at the top.
                      7. On Category Display Page CTY I pasted in <mvt:item name="readytheme" param="contentsection( 'isLandingPage' )" /> just after the body tag to see if the content section and the code inside it was working. It works as expected.
                      8. NEW: See Screen Cap - In the top box, the template (CTY), I pasted in the following code just after the body tag. The placement of this code is important because the css and jquery may have to load at different times based on when the elements load into the browser, and when the jquery fires (but I'll figure that out later). For now, I just have a very simple style in the content section to turn all the links <a> pink. Then I will know the miva script is working.
                      Code:
                      <mvt:item name="customfields" param="Read_Category_Code( l.settings:category:code, 'isLandingPage', l.settings:customcat )" />
                      <mvt:eval expr=l.isLandingPage"/>
                      <mvt:if expr="g.isLandingPage EQ 1">
                      <mvt:item name="readytheme" param="contentsection( 'isLandingPage' )" />
                      </mvt:if>

                      Comment


                        #12
                        From your #8 screenshot, you are calling the custom field twice, which isn't necessary. I believe Bruce suggested adding it at the top of the page so that the custom field data could be used anywhere in the page after that. So, since Bruce is smart, change the line at the very top of #8 screenshot to:

                        Code:
                        <mvt:item name="customfields" param="Read_Category_Code( l.settings:category:code, 'isLandingPage', g.isLandingPage )" />
                        Then, in the section you have in code tags above:

                        Code:
                        <mvt:eval expr="g.isLandingPage" />
                        <mvt:if expr="g.isLandingPage EQ 1">
                        <mvt:item name="readytheme" param="contentsection( 'isLandingPage' )" />
                        </mvt:if>
                        If you have your stuff set up correctly, you should see the word 'test' on the page. If you do, remove the mvt:eval and change your custom field back to a checkbox.
                        Last edited by Leanne; 03-30-18, 05:51 PM.

                        Comment


                          #13
                          Hallelujah!! I was able to get exactly the right recipe, and it is WORKING now. Thank you all so much for your patience with me. For rookies like me that come along later wanting to know how to do this. Here is the final list of steps.

                          Inserting a Custom Field into a Category Page, and using a checkbox to insert CSS or jQuery from a Content Section:
                          • See Screen Cap - On the custom fields page, I created a custom field
                          • See Screen Cap - On a random category page I verified that the new custom field is showing up on category page as expected. I also checked the box to turn it on.
                          • See Screen Cap - On the content sections page, I created a content section "isLandingPage" and put in a very simple CSS style that will turn all links <a> pink. Then I will know the miva script is working.
                          Code:
                          <style> a {color:pink; }</style>
                          • See Screen Cap - On Category Display Page CTY I turned on custom fields Item
                          • See Screen Cap- On Category Display Page CTY I verified that the readythemes Item was activated.
                          • See Screen Cap - On Category Display Page CTY I pasted in a Read_Category into the template box at the top.
                          Code:
                          <mvt:item name="customfields" param="Read_Category_Code( l.settings:category:code, 'isLandingPage', g.isLandingPage )" />
                          • Optional step to test your code: On Category Display Page CTY I pasted in <mvt:item name="readytheme" param="contentsection( 'isLandingPage' )" /> just after the body tag to see if the content section and the code inside it was working. It works as expected.
                          • Optional step to test your code: See Screen Cap - In the top box, the template (CTY), I pasted in the following code just after the body tag. The first line is an “eval” which will test to see if the custom field is working. What should happen is you see the number 1 at the very top of your category page.
                          Code:
                          <mvt:eval expr="g.isLandingPage" />
                          <mvt:if expr="g.isLandingPage EQ 1">
                          <mvt:item name="readytheme" param="contentsection( 'isLandingPage' )" />
                          </mvt:if>
                          • When you remove the first line of the previous step, and click update you should have pink links! Woot!

                          So for those of you that might be wondering, what’s the practical application of pink links? Not much at this point :) But as I mentioned above, I plan on making this particular category page a landing page from a google adwords campaign. I wanted to use CSS to remove various parts of the page like the navigation and footer, while still being able to use the functionality of this template to be able to list the grid of products after some flashy promotional content. I will also eventually add a bit of jQuery to convert this page from a 1/4 - 3/4 column layout to a full-width layout.

                          I haven’t gotten around to experimenting with that stuff yet though, because I just needed to get the Miva code working. Maybe when it’s finished I’ll report back with a screen shot!

                          Thank you all again!

                          Comment

                          Working...
                          X