Board index Themes bulletproof ->ADDTHIS

Skinning and designing Serendipity (CSS, HTML, Smarty)
vtpw
 
Posts: 2
Joined: Sat Apr 04, 2015 4:53 am

Postby vtpw » Sat Apr 04, 2015 5:05 am

Enabling ADDTHIS in the Theme shows the Share buttons fine but when I go to "Share a certain Title post with Twitter and Facebook" it always Shares the entire PAGE instead of Sharing just the Title however when I Share with G+ it Shares just fine. Seems Twitter and Facebook truncate the Title adding stuff like %3 where a / is suppose to go.

I searched and found one post with the same problem but no details on whether he fixed it. I even did a clean re-install with the latest s9y with same result. The blog is located here: http://news.virtualtech.pw/ Hope someone has a hint on what's happening. Thanks

User avatar
yellowled
Regular
 
Posts: 6815
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany

Postby yellowled » Sat Apr 04, 2015 6:15 pm

vtpw wrote:Seems Twitter and Facebook truncate the Title adding stuff like %3 where a / is suppose to go.

Yup. Judging from a quick test, all this seems to work fine if the blog uses URL rewriting (meaning “search engine friendly URLs”), which your blog does not. Seems as if the AddThis widget does not escape special characters in the URL properly if no URL rewriting is used.

To explain this better: If you did use URL rewriting, your URLs would be

Code: Select all
/archives/id-title.html

instead of

Code: Select all
/index.php?/archives/id-title.html

It might be that this is fixed in later versions of s9y. You're currently using 1.6.2. Current stable is 2.0.1, but even compared to the latest 1.x version (1.7.8), that's pretty old. I know we changed some things about escaping URLs, but I'm not sure if the part that creates the AddThis widget was changed.

For reference, this is the part I mean in BP's entries.tpl

Code: Select all
<script type="text/javascript">
addthis_url = '{$entry.rdf_ident|escape:url}';
addthis_title = '{$entry.title|escape:url}';
addthis_pub = '{$template_option.addthisaccount|escape}';
</script>

It might be that these are not escaped properly, but I doubt it since the source code of your blog shows the proper values. So it might be that this is an issue on AddThis's end. I can really test that easily, I'd need to set up a test blog which does not URL rewriting to verify.

YL
amazon Wishlist - Serendipity-Podcast (German only, sorry)

User avatar
Don Chambers
Regular
 
Posts: 3576
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA

Postby Don Chambers » Sat Apr 04, 2015 6:25 pm

Yes, I see it. You have a link like this:

news.virtualtech.pw/index.php?/archives/53-A-Black-and-Blue-Life-A-Coal-Miner-Becomes-a-Photographer-of-Exquisite-Waves-and-Seascapes.html

And a facebook share yields an escaped link like this:
news.virtualtech.pw/index.php?%2Farchives%2F53-A-Black-and-Blue-Life-A-Coal-Miner-Becomes-a-Photographer-of-Exquisite-Waves-and-Seascapes.html

First thing I would like to know is if this happens when you are using URL rewriting... if your server supports this option, give it a try. You are running serendiptiy 1.6.2 (getting fairly old), so you can get to this option via Administration -> Configuration -> Appearance and Options -> URL Rewriting. Try using "Use Apache mod rewrite". That will get rid of the/index.php? portion of all of your links.

User avatar
Don Chambers
Regular
 
Posts: 3576
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA

Postby Don Chambers » Sat Apr 04, 2015 6:32 pm

Looks like YL and I posted much the same thing at the same time... his explanation is far more detailed! :lol:

User avatar
yellowled
Regular
 
Posts: 6815
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany

Postby yellowled » Sat Apr 04, 2015 6:34 pm

Reproducable even in 2.x (didn't expect anything else) – if URL rewriting is not active, the slashes in the URL don't seem to “translate” properly to AddThis. The URL looks fine in the page's source code, though.

Code: Select all
<div class="addthiswidget">
    <a href="http://www.addthis.com/bookmark.php?v=250" onmouseover="return addthis_open(this, '', encodeURIComponent('http://test.netzgestaltung.net/index.php?/archives/1-Test.html'), encodeURIComponent('Test'));" onmouseout="addthis_close()" onclick="return addthis_sendto()" title="Bookmark and Share" target="_blank">

However, within the AddThis share screen, this URL becomes

Code: Select all
http://test.netzgestaltung.net/index.php?%2Farchives%2F1-Test.html#.VSARdtkEx28.twitter

I assume the issue here is the unescaped ? character, but I'm not sure how to fix that because in BP's entries.tpl, this code is escaped using escape:url

Also, I am able to google issues with questions marks in URL and AddThis, but I can't look up the results because AddThis's support page is login only. :shock:

YL
amazon Wishlist - Serendipity-Podcast (German only, sorry)

User avatar
Don Chambers
Regular
 
Posts: 3576
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA

Postby Don Chambers » Sat Apr 04, 2015 7:57 pm

@YL - did you notice there are actually two different addthis code blocks? The option to show the entry footer below the entry has a different addthis code block than when entry footer is below the title, or split.

Regardless, Did you try removing the escape:url to see if it solves the problem in your test site?

User avatar
yellowled
Regular
 
Posts: 6815
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany

Postby yellowled » Sat Apr 04, 2015 10:03 pm

Don Chambers wrote:did you notice there are actually two different addthis code blocks?

I did not.

However, when I initially checked this out, I was looking at the source code of vtpw's blog. There, the HTML for the AddThis widget includes

Code: Select all
onmouseover="return addthis_open(this, '', encodeURIComponent('http://news.virtualtech.pw/index.php?/archives/55-Spring-and-Winter.html'), encodeURIComponent('Spring%20and%20Winter'));"

which makes me think that the URL to the entry is in fact encoded properly on our end. (I might be wrong there.)

Don Chambers wrote:Did you try removing the escape:url to see if it solves the problem in your test site?

No. Why would it? As far as I understand it (feedback from someone who knows more about escaping in Smarty like Ian might be good here), the escape:url actually escapes the part of the URL that encodeURIComponent does not. The problem seems to be that neither of the two escapes the question mark …?

I really don't know, just guessing here.

YL
amazon Wishlist - Serendipity-Podcast (German only, sorry)

vtpw
 
Posts: 2
Joined: Sat Apr 04, 2015 4:53 am

Postby vtpw » Fri Apr 10, 2015 10:50 pm

You guys are incredible ! I wish I seen your replies earlier. I must of Not ticked "Notify me when a reply is posted" so I logged on now and sure enough, best replies! Thanks so much. I know my version 1.6.x a bit old and newest version has a nicer interface etc,. in fact I should update to to it pretty soon though I did install it along side 1.6.x just to see if the ADDTHIS portion was any different but it had the same results as 1.6.2. With that said and your advice, problem is now solved!! Many many Thanks.. Now I can start Sharing to Twitter and my Twitter naturally shares to Facebook.. so this is what worked in case anyone else has the problem on a Unix server:


Go-to: Administration -> Configuration -> Appearance and Options -> URL Rewriting. Try using "Use Apache mod rewrite".

Now It grabs the Title and Shares to at least G+, Twitter as well as Facebook and most likely all the rest you would ever need your articles shared too. So thanks guys!! Problem now solved:-)



Return to Themes

Who is online

Users browsing this forum: No registered users and 2 guests