Announcement

Collapse
No announcement yet.

Rich Snipetts / schema

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

    #16
    Ed. When posting bits of code, best type them between [ c o d e ] and [ / c o d e ] tags (type them without the spaces) as it makes it much more readable.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #17
      Hi,

      I have finally got around to attempting to implement microdata.
      I have used Eds Code from post #13

      But I have an issue

      I changed "SectionImageFileName" to "ProductImageFileName".

      However, my product images are not 'loose' in the 'Site1' folder. They are in a subfolder Images\Products\

      So the below code;

      Code:
      <meta itemprop="image" content="<actinic:variable name="CatalogURL" /><actinic:variable name="ProductImageFileName" />" />
      returns the image location (on the structured data testing tool) as;

      ...arka-shop.co.uk/acatalog/Images\products\Brass-Flesh-Tunnels.jpg

      How do I strip out "Images\Products\" ?

      Cheers.
      Arka Tribal Jewellery

      Comment


        #18
        Are you checking this on the live site or just Preview?

        Preview will use the full path but live site should have just the plain filename.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #19
          Not sure if it's in your SD 2014 but there is nowadays a ProductImageFilenameRaw that you can use.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #20
            Thanks Norman,
            I am checking this on a live site.

            I will try ProductImageFilenameRaw and see if that works.
            Arka Tribal Jewellery

            Comment


              #21
              That sorted it Norman, thanks again
              Arka Tribal Jewellery

              Comment


                #22
                Also, for anyone else enabling microdata..
                The code on post13 also returns the price with a "J" in front as
                "J9.95"
                even with Normans edit;

                Code:
                <meta itemprop="price" content="£<actinic:block php="true">echo preg_replace('/[^\d\.]/', '', '<actinic:block type="pricelist"><actinic:block if="%3cactinic%3avariable%20name%3d%22ListIndex%22%20%2f%3e%20%3d%3d%201"><actinic:variable name="TaxInclusivePrice" selectable="false" /></actinic:block></actinic:block>');</actinic:block>" />
                So I removed the "£" from Normans line and now the price populates without any odd characters, and also without a currency symbol , which is I believe how Google now wants it, as the currency is specified seperately.

                This code works fine on V14 with no errors in the testing tool.

                Code:
                <!-- microdata start -->
                <div itemscope itemtype="http://data-vocabulary.org/Product">
                <meta itemprop="image" content="<actinic:variable name="CatalogURL" /><actinic:variable name="ProductImageFilenameRaw" />" />
                <meta itemprop="identifier" content="mpn:<actinic:variable name="ProductReference" />"/>
                <meta itemprop="name" content="<actinic:variable name="ProductName" />" />
                <meta property="og:type" content="product" />
                <meta property="og:title" content="<actinic:variable name="ProductName" />" />
                <meta property="og:url" content="<actinic:block php="true">echo '<actinic:variable name="CatalogURL" encoding="perl" selectable="false" />' . basename('<actinic:variable name="ProductPageName" encoding="perl" selectable="false" />');</actinic:block>" />
                </div>
                <div class="purchase_data" itemprop="offerDetails" itemscope itemtype="http://data-vocabulary.org/Offer">
                <meta itemprop="condition" content="new" />
                <meta itemprop="currency" content="GBP" />
                <meta itemprop="price" content="<actinic:block php="true">echo preg_replace('/[^\d\.]/', '', '<actinic:block type="pricelist"><actinic:block if="%3cactinic%3avariable%20name%3d%22ListIndex%22%20%2f%3e%20%3d%3d%201"><actinic:variable name="TaxInclusivePrice" selectable="false" /></actinic:block></actinic:block>');</actinic:block>" />
                <meta itemprop="availability" content="In_stock" />
                <meta itemprop="seller" content="<actinic:variable name="CompanyName" />"/>
                </div>
                <!-- microdata end -->
                Arka Tribal Jewellery

                Comment


                  #23
                  While ProductImageFileNameRaw does the job for product images you'd be stuck if you were using a user Variable of type File (there's no raw option available). Luckily SellerDecks built-in PHP can generate a raw filename. E.g. We'll use ProductImageFileName to demonstrate but you can substitute in your own variables name instead:
                  Code:
                  <actinic:block php="true">echo basename(str_replace('\\', '/', '<actinic:variable name="ProductImageFileName" encoding="perl" selectable="false"/>'));</actinic:block>
                  Three things are done above - lets assume that ProductImageFileName contains

                  files\newfiles\testimage.jpg

                  1) We need encoding="perl" selectable="false" within the variable instance so we can use it as a PHP single quoted string literal. PHP will now see:
                  Code:
                  echo basename(str_replace('\\', '/', 'files\\newfiles\\testimage.jpg'));
                  2) SellerDeck uses \ as the folder separator which means a sub-folder structure like files\newfiles\testimage.jpg could be interpreted as having a newline and a tab ( \n \t ) in it. The str_replace fixes that by turning all \ into /. PHP will now see:
                  Code:
                  echo basename('files/newfiles/testimage.jpg');
                  3) And finally PHP's basename function returns just the testimage.jpg part.
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #24
                    Thanks for this extra info Norman, for a layman like me can you tell me what you mean by a Variable of Type file? Do you just mean something other than an image? (maybe I'm confused because you use an image as an example?)
                    Arka Tribal Jewellery

                    Comment


                      #25
                      When you create a Variable, you have to choose what type of thing it will hold. Done via Edit Variable / Type setting. E.g. Text, Number, True/False, Filename, etc.

                      It's Filename we're interested in here as this lets you browse for a file-name, rather than just typing the contents in.

                      It's only Filename type variables that need all the processing as post #23 above to get rid of pathnames, unwanted backslashes, etc.
                      Norman - www.drillpine.biz
                      Edinburgh, U K / Bitez, Turkey

                      Comment


                        #26
                        Your code works great on my pretty much out the box 2016 site, brilliant.
                        https://www.harrisontelescopes.co.uk/

                        Ed Harrison - Menmuir Scotland

                        Comment

                        Working...
                        X