Announcement

Collapse
No announcement yet.

Including canonical URLs in an email

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

    Including canonical URLs in an email

    I'm trying to get a link to the canonical URL for a product into an email template so when I send customers a follow up email asking for feedback on a product, the email contains a link to that product's page on my site. I'm using URI management and have created canonical URLs for all my products.

    It seems like it should be easy to do this by adding the token &mvte:product:link; to the page template. I'm using that to generate the canonical URL on the PROD page template, and it works fine. But for some reason, I can't get it to work on my email page template. I've tried enabling all sorts of different items for this page (including everything that's enabled on the PROD page), and I can't get that to return a value on this page. I've also tried to use the variables that are used to create the product URIs in the URI management settings, but I can't get those to function on the page either.

    Any ideas about how I can get the canonical URL to appear in an email?
    Todd Gibson
    Oliver + S | Sewing Patterns for Kids and the Whole Family

    #2
    The URI_Load_Item_Canonical function might work.

    Found here: http://docs.miva.com/template-langua...ement-examples
    Code:
    <mvt:assign name="l.uri:store_id" value="g.Store:id" />
    <mvt:assign name="l.uri:screen" value="''" />
    <mvt:assign name="l.uri:page_id" value="0" />
    <mvt:assign name="l.uri:cat_id" value="0" />
    <mvt:assign name="l.uri:product_id" value="1" />
    <mvt:do file="g.Module_Feature_URI_DB" name="l.have_uri" value="URI_Load_Item_Canonical( l.uri, l.settings:canonical_uri )" />
    <mvt:if expr="l.have_uri">
               &mvt:canonical_uri:canonical; <br>
               &mvt:canonical_uri:cat_id;<br>
               &mvt:canonical_uri:page_id;<br>
               &mvt:canonical_uri:status;<br>
               &mvt:canonical_uri:store_id;<br>
               &mvt:canonical_uri:uri;<br>
    </mvt:if>
    http://www.alphabetsigns.com/

    Comment


      #3
      I tried that as well and had no luck. But I'm wondering if it's how I've implemented it.

      I'm trying to use this in an array that generates all items in an order. I want to include a link to the item's canonical URL. I'm able to get the &mvt:canonical_uri:canonical; entity to appear on the page in the <mvt:if expr="l.have_uri"> expression, but it doesn't return any value. The field is null when the page is generated. But all the other entities in that array (item:code, item:name, etc.) return the correct values for each item in the order.

      Here's a simplified version of code I'm using

      Code:
      <mvt:foreach iterator="item" array="order:items">
      <tr>
      <td><a href="https://oliverands.com/product/&mvte:item:code;.html"><img src="http://osimg.net/images/product/&mvte:item:code;/&mvte:item:code;_Garment.jpg"   /></a></td>                                    
      <td >&mvt:item:name;</td>                          
      <td><a href="https://oliverands.com/product/&mvta:item:code;.html"><img src="http://osimg.net/mlist/responsive_assets/Review.jpg" alt="Review the &mvt:item:name;"></a></td>
      <td>
          <mvt:assign name="l.uri:store_id" value="g.Store:id" />
          <mvt:assign name="l.uri:screen" value="''" />
          <mvt:assign name="l.uri:page_id" value="0" />
          <mvt:assign name="l.uri:cat_id" value="0" />
          <mvt:assign name="l.uri:product_id" value="1" />
          <mvt:do file="g.Module_Feature_URI_DB" name="l.have_uri" value="URI_Load_Item_Canonical( l.uri, l.settings:canonical_uri )" />
          <mvt:if expr="l.have_uri">
                 &mvt:canonical_uri:canonical; <br>
                 &mvt:canonical_uri:cat_id;<br>
                 &mvt:canonical_uri:page_id;<br>
                 &mvt:canonical_uri:status;<br>
                 &mvt:canonical_uri:store_id;<br>
                 &mvt:canonical_uri:uri;<br>
          </mvt:if>                                  
      </td>
      </tr>
      </mvt:foreach>
      Is there a problem with how this is used within the array that is keeping the entity from having a value?
      Todd Gibson
      Oliver + S | Sewing Patterns for Kids and the Whole Family

      Comment


        #4
        Try changing the product_id value:

        Code:
         <mvt:assign name="l.uri:product_id" value="l.settings:item:id" />
        http://www.alphabetsigns.com/

        Comment


          #5
          That didn't do the trick--but it got closer. That variable didn't pull in the products in the order, but when I replaced it with this, it did.

          Code:
          <mvt:assign name="l.uri:product_id" value="l.settings:item:code" />
          But for some reason even though I'm able to get a value assigned, this isn't returning the canonical URI for me.

          Code:
          <mvt:do file="g.Module_Feature_URI_DB" name="l.have_uri" value="URI_Load_Item_Canonical( l.uri, l.settings:canonical_uri )" />
          Could it be that there's an item I need to assign to the page to get that function to work? Or will it not work on certain types of pages?
          Todd Gibson
          Oliver + S | Sewing Patterns for Kids and the Whole Family

          Comment


            #6
            My bad, try:

            Code:
             
             <mvt:assign name="l.uri:product_id" value="l.settings:item:product_id" />
            Make sure order_contents item is assigned to page.
            http://www.alphabetsigns.com/

            Comment


              #7
              Thanks so much! That does the trick.
              Todd Gibson
              Oliver + S | Sewing Patterns for Kids and the Whole Family

              Comment


                #8
                So glad I found this post. I struggled with this for hours trying to link to the product page from the Review Request page template. This code didn't work: https://docs.miva.com/code-samples/load-canonical-uri.

                But the below code does.
                Code:
                <mvt:assign name="l.uri:store_id" value="g.Store:id" />
                <mvt:assign name="l.uri:screen" value="''" />
                <mvt:assign name="l.uri:page_id" value="0" />
                <mvt:assign name="l.uri:cat_id" value="0" />
                <mvt:assign name="l.uri:product_id" value="l.settings:item:product_id" />
                <mvt:do file="g.Module_Feature_URI_DB" name="l.have_uri" value="URI_Load_Item_Canonical( l.uri, l.settings:canonical_uri )" />
                https://www.domain.com&mvt:canonical_uri:uri;

                Comment


                  #9
                  What's wrong with just using:


                  <mvt:do file="g.Module_Feature_URI_DB" name="l.success" value="URI_Load_Product_Canonical(product_id, l.settings:uri)" />

                  &mvt:uri:uri;

                  ?
                  you'd need to use l.settings:item:id (or whatever the local variant is for the product id.)
                  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


                    #10
                    I can't get that to work...
                    I tried:
                    Code:
                    <mvt:do file="g.Module_Feature_URI_DB" name="l.success" value="URI_Load_Product_Canonical(l.settings:item:product_id, l.settings:uri)" />

                    Comment


                      #11
                      what does l.settings:item:product_id evaluate too?

                      pro tip: ALWAYS verify your inputs before assuming something doesn't 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


                        #12
                        Thanks for the tip and making me look at this closer.

                        So I was getting a value of 77 for l.settings:item:product_id so it was working. After some more tweaks I was able to get it to output.

                        Code:
                        <mvt:do file="g.Module_Feature_URI_DB" name="l.success" value="URI_Load_Product_Canonical(l.settings:item:product_id, l.settings:uri)" />
                        <a href="https://www.domain.com&mvt:uri:uri;">Product Link</a>


                        Comment

                        Working...
                        X