Keyword

Change Twitter Tweeted text

  • Matt Medley
  • Matt Medley's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 9 months ago #134853 by Matt Medley
Change Twitter Tweeted text was created by Matt Medley
Hi guys,

Is there anyway to change the tweeted text when you use the twitter share button on items? Right now it tweets the browser title. But my browser title is often too long, it would be great if I could just tweet the item's title from the tweet button.

Thank you for your help!

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 9 months ago #134870 by Krikor Boghossian
Replied by Krikor Boghossian on topic Change Twitter Tweeted text
You can change the twitter text by adding the data-text attribute to the button.

If you haven't overriden your template please do. This post will help you. nuevvo.com/blog/item/84-k2-inheritance-sub-templating

Locate the twitter button
<?php if($this->item->params->get('itemTwitterButton',1)): ?>
			<!-- Twitter Button -->
			<div class="itemTwitterButton">
				<a href="https://twitter.com/share" class="twitter-share-button" data-count="horizontal"<?php if($this->item->params->get('twitterUsername')): ?> data-via="<?php echo $this->item->params->get('twitterUsername'); ?>"<?php endif; ?>>
			<?php endif; ?>

and add the attribute
			<?php if($this->item->params->get('itemTwitterButton',1)): ?>
			<!-- Twitter Button -->
			<div class="itemTwitterButton">
				<a href="https://twitter.com/share" class="twitter-share-button" data-text="<?php echo $this->item->title; ?>" data-count="horizontal"<?php if($this->item->params->get('twitterUsername')): ?> data-via="<?php echo $this->item->params->get('twitterUsername'); ?>"<?php endif; ?>>
			<?php endif; ?>

All the available attributes can be found here: dev.twitter.com/web/tweet-button

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum