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.
Announcement
Collapse
No announcement yet.
Rich Snipetts / schema
Collapse
X
-
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" />" />
...arka-shop.co.uk/acatalog/Images\products\Brass-Flesh-Tunnels.jpg
How do I strip out "Images\Products\" ?
Cheers.
Comment
-
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
-
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
-
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>" />
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 -->
Comment
-
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>
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'));
Code:echo basename('files/newfiles/testimage.jpg');
Norman - www.drillpine.biz
Edinburgh, U K / Bitez, Turkey
Comment
-
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
Comment