Adding to data-text in tweet button


#1

Hello,

The code for the tweet button on my blog is:

<!-- Twitter tweet button Start --><b:if cond='data:blog.pageType != &quot;static_page&quot;'>
<div style='text-align:left;padding:5px 5px 5px 0;'>
<a class='twitter-share-button' data-count='horizontal' data-related='' data-via='johnsumer' expr:data-text='data:post.title' expr:data-url='data:post.url' href='http://twitter.com/share'>Tweet</a>
<script src='http://platform.twitter.com/widgets.js' type='text/javascript'/>
</div>
</b:if>
<!-- Twitter tweet button End -->

I know that data-text sets the actual text to be tweeted and it currently gives the post title on the blog, e.g.: “I have a cat”. But I want it to appear it contatining the blog title, followed by ': ’ and then the post title, e.g. “My Blog: I have a cat”. How should I change the above code to do that?

Thanks,

Can


#2

Depends on your blogging software, but if you are using Wordpress you could have data-text=’’<?php bloginfo('name'); ?>: <?php wp_title("",true); ?>


#3

Thank you for the reply, however I’m using blogspot.


#4

what should I do in blogspot?


#5

Same problem here. How can you do it in blogspot?


#6

It’s possibile to have it in iframe code for wordpress?


#7

yes it is, but I’m using blogspot :confused:


#8

anyone?


#9

I’m using
expr:data-text='data:post.title + " by @EXDE601E"‘
on my blog, so I guess the solution for you would be:
expr:data-text=’"My blog: " + data:post.title’
Wrap everything in single quotes, wrap normal text in escaped quotes and link it together with +.


#10

Yes!!

Thanks a lot, works exactly the way I want!

Cheers,

Can


#11

BTW, because of the newly introduced domain redirect based on the country where the viewer accesses the blog you should use expr:data-url=‘data:post.canonicalUrl’ instead of expr:data-url=‘data:post.url’.


#12

Roger that.


#13

hi i ma using tweet button into my website i try both iframe & javascript cannot add dynamically url …?


#14