• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed AddThis: Publisher ID not being sent $xenOptions.addThis.pubId

Chris D

XenForo developer
Staff member
#1
As per a request I am currently looking at replacing the default share_page functionality with AddThis rendered buttons, that look like this:

share3.png

I have been using a combination of code from the addthis_ajax functionality and code available via the AddThis website.

The code with the bug is the following:

<script type="text/javascript">

**snip**

XenForo.loadJs("http://s7.addthis.com/js/250/addthis_widget.js#domready=1{xen:if {$xenOptions.addThisPubId}, '&pubid={xen:jsescape $xenOptions.addThis.pubId}'}");

</script>

I have highlighted the problem in red, with the correct in green. As far as I can tell $xenOptions.addThisPubId doesn't exist, so the xen:if will always come back empty and never pull the correct variable which is $xenOptions.addThis.pubID.

I have implemented this in my code and whereas before View Source would look like:

Code:
<script type="text/javascript">
 
var addthis_share_config = 
{
    url: "http://www.valvetime.net/forum/",
}
**snip**
 
XenForo.loadJs("http://s7.addthis.com/js/250/addthis_widget.js#domready=1");
 
</script>
It now looks like:

Code:
<script type="text/javascript">
 
var addthis_share_config = 
{
    url: "http://www.valvetime.net/forum/",
}
**snip**
 
XenForo.loadJs("http://s7.addthis.com/js/250/addthis_widget.js#domready=1&pubid=ra-4f97c4942ed9a5b9");
 
</script>
 

Jake Bunce

XenForo moderator
Staff member
#2
Confirmed in 1.1.2

The "addThisPubId" option does not exist. Clearly a typo:

Admin CP -> Appearance -> Templates -> addthis_ajax

Replace:

Code:
XenForo.loadJs("http://s7.addthis.com/js/250/addthis_widget.js#domready=1{xen:if {$xenOptions.addThisPubId}, '&pubid={xen:jsescape $xenOptions.addThis.pubId}'}");
With:

Code:
XenForo.loadJs("http://s7.addthis.com/js/250/addthis_widget.js#domready=1{xen:if {$xenOptions.addThis.pubId}, '&pubid={xen:jsescape $xenOptions.addThis.pubId}'}");