1. 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

Discussion in 'Resolved Bug Reports' started by Chris D, Apr 27, 2012.

  1. Chris D

    Chris D XenForo Developer Staff Member

    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>
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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}'}");
    
     
    Yorick likes this.
  3. Mike

    Mike XenForo Developer Staff Member

    Fixed.
     
    Yorick likes this.
  4. Chris D

    Chris D XenForo Developer Staff Member

    Thanks Mike :)
     

Share This Page