AddToAny modification

Discussion in 'Templates, HTML, CSS, and Design Help' started by zooi, Jan 13, 2011.

  1. zooi Customer

    C68 version: v4.2.1 Developer, template Sigma


    Hello,

    I have added Addtoany social buttons to listingextras.tpl.

    The AddToAny code is

    Code:
    <!-- AddToAny BEGIN -->
    <div class="a2a_kit a2a_default_style">
    <a class="a2a_dd" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.kidsspullen.nl&linkname=Marktplaats%20kidsspullen.nl">Deel deze advertentie | </a>
    <a class="a2a_button_facebook"></a>
    <a class="a2a_button_twitter"></a>
    <a class="a2a_button_email"></a>
    <a class="a2a_button_hyves"></a>
    </div>{literal}
    <script type="text/javascript">
    var a2a_config = a2a_config || {};
    a2a_config.linkname = 'Marktplaats Kidsspullen';
    a2a_config.linkurl = "http://www.kidsspullen.nl";
    a2a_config.onclick = 1;
    a2a_config.locale = "nl";
    </script>
    <script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>{/literal}
    <!-- AddToAny END -->
    This works. Only when you click on the Twitter button it will post in Twitter:

    Marktplaats Kidsspullen Kidsspullen via @AddToAny

    This is not so nice so I have tried to modify the code from AddToAny with:


    a2a_config.linkname = 'Marktplaats Kidsspullen,{title}';
    a2a_config.linkurl = "http://www.kidsspullen.nl{$smarty.server.REQUEST_URI}";

    But no succes yet. It just output the added values {..} and if I put the values between {literal} {/literal} it also screw up the website?

    My question is it possible to add the listing title and listing url to the AddToAny script?

    Thank you for your reply
  2. Lhotch curmudgeon

    anything between <script type="text/javascript"> </script> is going to be handled by the browser as javascript and javascript doesnt know or care about smarty so you cant just plop smarty vars into js.

    I would try using the php vars instead, something like this....

    a2a_config.linkname = "Marktplaats Kidsspullen,<?= $title ?>";
  3. Blair Administrator

    Just FYI.......

    We had a hosted customer using the 'AddToAny' feature and it slowed down his site A LOT!
    The call to the external javascript file was causing the problem so you may want to make all necessary resources available from your own server.
  4. zooi Customer

    Thank you Larry and Blair for your input and prompt reply.
  5. zooi Customer

    Larry,

    With php it didn't work out...but below code worked perfect.

    Code:
    [COLOR="Red"]{literal}[/COLOR]
    <script type="text/javascript">
    var a2a_config = a2a_config || {};
    a2a_config.linkname = "Kidsspullen: [COLOR="YellowGreen"]{/literal}[/COLOR]{$title}[COLOR="Red"]{literal}[/COLOR]";
    a2a_config.linkurl = "[COLOR="YellowGreen"]{/literal}[/COLOR]http://www.kidsspullen.nl{$smarty.server.REQUEST_URI}{[COLOR="Red"]literal}[/COLOR]";
    a2a_config.onclick = 1;
    a2a_config.locale = "nl";
    </script>
    <script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>[COLOR="YellowGreen"]{/literal}[/COLOR]

Share This Page