{"id":2258,"date":"2016-08-15T17:16:56","date_gmt":"2016-08-15T23:16:56","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=2258"},"modified":"2021-11-21T13:00:24","modified_gmt":"2021-11-21T19:00:24","slug":"example-of-customizing-sharetribe-com","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/2258","title":{"rendered":"Example of customizing a marketplace on sharetribe.com"},"content":{"rendered":"<p>Here&#8217;s an example of some javascript code I wrote to customize a sharetribe.com marketplace.<\/p>\n<p>This code adds a LinkedIn share button to the listing page.<\/p>\n<p>Comments inline.<\/p>\n<pre>window.onload = function () {  \/\/ make sure you run after the document has been loaded, otherwise you won't have access to jquery.\r\n\t$( document ).ready(function() {\r\n    \t\tstartcustomization();\r\n\t});\r\n}\r\n\r\nfunction startcustomization() {\r\n\tconsole.log(\"cust started\");  \/\/ good old debugging log statements.\r\n \tvar d = document.createElement(\"div\");  \/\/ adding a div to hold our stuff\r\n\td.className = \"listing-tweet-button\"    \/\/ leveraging a existing css class\r\n\r\n \tvar s = document.createElement(\"script\");  \/\/ inject a script tag\r\n    \ts.type = \"text\/javascript\";\r\n    \ts.src = \"\/\/platform.linkedin.com\/in.js\";  \/\/ this code is all from https:\/\/developer.linkedin.com\/plugins\/share \r\n        var textnode = document.createTextNode(\"lang: en_US\");\r\n\td.appendChild(s);\r\n\r\n \tvar s = document.createElement(\"script\");  \/\/ had to inject both script tags, otherwise they weren't executed.\r\n    \ts.type = \"IN\/Share\";\r\n\t\/\/ commented out: s[\"data-url\"] = \"http:\/\/www.foo.com\";  If you wanted to share a different page than the one that the sharebutton was on, you'd use this.\u00a0 The share button defaults to sharing the page it is installed on.\u00a0 \r\n\td.appendChild(s);\r\n\r\n\t$(\".listing-social\").append(d);  \/\/ find where the other share buttons are, and append our div\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>You can, of course, stack as many interesting custom functions as you&#8217;d like into this script.\u00a0 Do make sure you&#8217;re hosting the script on an SSL server (an S3 bucket will do fine) otherwise the script won&#8217;t be loaded, since sharetribe.com runs SSL only.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s an example of some javascript code I wrote to customize a sharetribe.com marketplace. This code adds a LinkedIn share button to the listing page. Comments inline. window.onload = function [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[78],"tags":[],"class_list":["post-2258","post","type-post","status-publish","format-standard","hentry","category-sharetribe"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/2258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2258"}],"version-history":[{"count":4,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/2258\/revisions"}],"predecessor-version":[{"id":2266,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/2258\/revisions\/2266"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}