Announcement

Collapse
No announcement yet.

Tool Kit > Redirect > Replacement code question

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

    Tool Kit > Redirect > Replacement code question

    I have some pages like this https://www.allfrom1supply.com/spray...-up-doors.html where there is a 'stub' product that uses an Alternate Display Page. This page has some code to redirect the stub product to a category. It was originally done for one item but over the years we ended up using it more often and now there are about a lot of redirect pages.

    I wanted to put all the redirect code in one page to tidy it up and tested it with the following Tool Kit code and it works fine. I wanted to see if there was some simple 'modern' Miva code to do the same thing in case Tool Kit eventually dies - otherwise I'll just use this.

    Code:
    <mvt:if expr="g.Product_Code EQ 'go-2-test-stub-1'">
    <mvt:item name="toolkit" param="headeroutput|Status|301 Moved Permanently" />
    <mvt:item name="toolkit" param="headeroutput|Location|https://www.allfrom1supply.com/system-1501-chem-bake-1-step-31.html" />
    <mvt:elseif expr="g.Product_Code EQ 'go-2-test-stub-2'">
    <mvt:item name="toolkit" param="headeroutput|Status|301 Moved Permanently" />
    <mvt:item name="toolkit" param="headeroutput|Location|https://www.allfrom1supply.com/system-1201-one-step-direct-to-metal-door-coating.html" />
    </mvt:if>
    Last edited by habreu; 02-09-22, 12:05 PM.

    #2
    The URI system lets you do that from the URI tab when editing your product/category. No need for any smt code.
    M.A.D.* since 1997

    http://www.scotsscripts.com

    *miva application developers

    Comment


      #3
      I tried that - in fact I think I posted about that some time back. It doesn't seem to work that way. I tried assigning the uri from the target category to the stub product, and then tried it from the stub product to the target category but doesn't work.
      Last edited by habreu; 02-10-22, 08:15 AM.

      Comment


        #4
        If you put


        https://www.allfrom1supply.com/syste...1-step-31.html

        as a 301 redirect on product

        https://www.allfrom1supply.com/syste...r-coating.html

        it should all work
        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
          In my tests just now that doesn't work. I tried going to the product and adding the 301 redirect to the category - still goes to the product. I tried going to the category and 301 redirect to the product and doesn't work. Product to Product works.

          Anyway the Alternate Display Page to redirect page works fine using toolkit so far. I just worry that Tool Kit functions will break at some point which is why I wondered if there was a 'modern' Miva equivalent of doing this.

          Code:
          <mvt:if expr="g.Product_Code EQ 'GO-2-EC-1501'">
          <mvt:item name="toolkit" param="headeroutput|Status|301 Moved Permanently" />
          <mvt:item name="toolkit" param="headeroutput|Location|https://www.allfrom1supply.com/system-1501-chem-bake-1-step-31.html" />
          <mvt:elseif expr="g.Product_Code EQ 'GO-2-EC-1201'">
          <mvt:item name="toolkit" param="headeroutput|Status|301 Moved Permanently" />
          <mvt:item name="toolkit" param="headeroutput|Location|https://www.allfrom1supply.com/system-1201-one-step-direct-to-metal-door-coating.html" />
          <mvt:elseif expr="g.Product_Code EQ 'GO-2-AXA-HGD'">
          <mvt:item name="toolkit" param="headeroutput|Status|301 Moved Permanently" />
          <mvt:item name="toolkit" param="headeroutput|Location|https://www.allfrom1supply.com/axalta-imron-polyurethane.html" />
          <mvt:elseif expr="g.Product_Code EQ 'GO-2-EC-1202-01'">
          <mvt:item name="toolkit" param="headeroutput|Status|301 Moved Permanently" />
          <mvt:item name="toolkit" param="headeroutput|Location|https://www.allfrom1supply.com/chem-bake-8000-xlt-1-gal.html" />
          <mvt:elseif expr="g.Product_Code EQ 'GO-2-EC-1202-05'">
          <mvt:item name="toolkit" param="headeroutput|Status|301 Moved Permanently" />
          <mvt:item name="toolkit" param="headeroutput|Location|https://www.allfrom1supply.com/chem-bake-8000-xlt-5-gal.html" />
          <mvt:elseif expr="g.Product_Code EQ 'GO-2-EC-4001-01'">
          <mvt:item name="toolkit" param="headeroutput|Status|301 Moved Permanently" />
          <mvt:item name="toolkit" param="headeroutput|Location|https://www.allfrom1supply.com/system-401-endura-crylic-self-storage-roll-door-paint.html" />
          <mvt:elseif expr="g.Product_Code EQ 'GO-2-EC-4001-05'">
          <mvt:item name="toolkit" param="headeroutput|Status|301 Moved Permanently" />
          <mvt:item name="toolkit" param="headeroutput|Location|https://www.allfrom1supply.com/system-401-endura-crylic-paint-to-restore-self-storage-doors.html" />
          <mvt:elseif expr="g.Product_Code EQ 'GO-2-EC-2000-01'">
          <mvt:item name="toolkit" param="headeroutput|Status|301 Moved Permanently" />
          <mvt:item name="toolkit" param="headeroutput|Location|https://www.allfrom1supply.com/bitmap-theme-branding-paint-1-gallon.html" />
          <mvt:elseif expr="g.Product_Code EQ 'GO-2-EC-2000-05'">
          <mvt:item name="toolkit" param="headeroutput|Status|301 Moved Permanently" />
          <mvt:item name="toolkit" param="headeroutput|Location|https://www.allfrom1supply.com/bitmap-theme-branding-paint-5-gallon.html" />
          </mvt:if>
          Last edited by habreu; 02-16-22, 09:10 AM.

          Comment


            #6
            just to be clear...since it aint. the 'redirect' goes ON the category/product/page that IS the desired target. You may also need to disable the 'redirected' product/category/page before it will work. but honestly have not tried anything other than product to product, cat to cat, etc.
            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
              just to be clear...since it aint. the 'redirect' goes ON the category/product/page that IS the desired target. You may also need to disable the 'redirected' product/category/page before it will work. but honestly have not tried anything other than product to product, cat to cat, etc.
              Thanks. I assume the redirect is meant to replace the old uri ie product 1 is now product 2. In my case I am creating a 'fake' product and am not replacing it with the target. In any case what I am doing works.

              It might be cool if Miva or a 3rd party 'menu link' item that could by added as a product, a category or a page and just be a redirect - so it would sit inline with the products on a CTGY page, or as a subcategory that redirects to a page for example and do it in a cleaner way than what I am doing. Makes sense in my head anyway.

              Some examples. This page has a subcategory which is 'COVID-19 Resources' but the subcategory really is a redirect to a page with links and resources.
              Capture.JPG
              This one is a sub-category that I put in multiple parents and so the 'fake category' is just redirected to the real one.
              Capture2.JPG

              This is the target page for a 'fake product' that has about 90+ colors each of which is a product. So this target is a category page with color chips which was easier for me than trying to code a massive swatch dropdown with chips especially since some of the colors have finishes that aren't available in some of the colors i.e. gloss, satin, semi-gloss. The 'fake product' that links to this is in a category with other real and more 'fake' products and we just wanted them to all be able to sit side by side in the parent "Paints & Coatings" category page. https://www.allfrom1supply.com/endur...-coatings.html

              Capture3.JPG

              Last edited by habreu; 02-21-22, 04:23 PM.

              Comment


                #8
                This should work.
                Code:
                <mvt:if expr="g.Product_Code EQ 'go-2-test-stub-1'">
                    <mvt:assign name="l.header" value="miva_output_header( 'Status', '301 Moved Permanently' )" />
                    <mvt:assign name="l.header" value="miva_output_header( 'Location', 'https://www.allfrom1supply.com/system-1501-chem-bake-1-step-31.html')" />
                <mvt:elseif expr="g.Product_Code EQ 'go-2-test-stub-2'">
                    <mvt:assign name="l.header" value="miva_output_header( 'Status', '301 Moved Permanently' )" />
                    <mvt:assign name="l.header" value="miva_output_header( 'Location', 'https://www.allfrom1supply.com/system-1201-one-step-direct-to-metal-door-coating.html')" />
                </mvt:if>

                Comment


                  #9
                  Originally posted by TipPro View Post
                  This should work.
                  Code:
                  <mvt:if expr="g.Product_Code EQ 'go-2-test-stub-1'">
                  <mvt:assign name="l.header" value="miva_output_header( 'Status', '301 Moved Permanently' )" />
                  <mvt:assign name="l.header" value="miva_output_header( 'Location', 'https://www.allfrom1supply.com/system-1501-chem-bake-1-step-31.html')" />
                  <mvt:elseif expr="g.Product_Code EQ 'go-2-test-stub-2'">
                  <mvt:assign name="l.header" value="miva_output_header( 'Status', '301 Moved Permanently' )" />
                  <mvt:assign name="l.header" value="miva_output_header( 'Location', 'https://www.allfrom1supply.com/system-1201-one-step-direct-to-metal-door-coating.html')" />
                  </mvt:if>
                  Thank you. Will test and replace.

                  Comment


                    #10
                    You can try the same functionality using Miva Script's g.Module_Redirect function.
                    Ex:
                    Code:
                    <mvt:if expr="g.Product_Code EQ 'go-2-test-stub-1'">
                    <mvt:do file="g.Module_Redirect" name="l.redirect" value="https://www.allfrom1supply.com/system-1501-chem-bake-1-step-31.html" />
                    </mvt:if>
                    <mvt:elseif expr="g.Product_Code EQ 'go-2-test-stub-2'">
                    <mvt:do file="g.Module_Redirect" name="l.redirect" value="https://www.allfrom1supply.com/system-1201-one-step-direct-to-metal-door-coating.html" />
                    </mvt:if>
                    
                    <mvt:if expr="l.redirect">
                    <mvt:do file="g.Module_Redirect" name="l.status" value="301" />
                    <mvt:do file="g.Module_Redirect" name="l.redirect" value="l.redirect" />
                    </mvt:if>

                    Comment

                    Working...
                    X