Keyword

K2 item social sharing - link problem

  • Dmitri Kharitidi
  • Dmitri Kharitidi's Avatar Topic Author
  • Offline
  • New Member
More
8 years 1 month ago #158444 by Dmitri Kharitidi
K2 item social sharing - link problem was created by Dmitri Kharitidi
Hi all,

I ran into a problem with the sharing buttons in K2 item (ie Twitter, FB G+).

For some reason the click on the sharing icon does not retrieve the full URL of the item. For instance, FB gives me the error 100:
www.facebook.com/dialog/return/close?error_code=100&error_message=href+should+represent+a+valid+URL#_=_

Similar problem with Twitter sharing: only part of URL is retrieved. " /joomla3/index.php/blog/item/31..." but the domain part is missing ( "www.mysite.com...")

I looked into the item php code, but it seems to be OK (according to my limited knowledge). Here it is:

<?php if($this->item->params->get('itemTwitterButton',1)): ?>
<a href="twitter.com/intent/tweet?text=item->title) . ' ' . $this->item->link ); ?>" class="sb-twitter" data-xtoggle="tooltip" data-placement="top" title="">
<i class="fa fa-twitter"></i>
</a>
<?php endif; ?>

So the question is: how do I make sure that the sharing function retrieves the full URL? Any advice or insights is greatly appreciated...
thank you!
Dmitri

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 1 month ago #158466 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 item social sharing - link problem
Hello, you should try using the default code.
		<?php if($this->item->params->get('itemTwitterButton',1)): ?>
		<!-- Twitter Button -->
		<div class="itemTwitterButton">
			<a href="https://twitter.com/share" class="twitter-share-button" data-lang="<?php echo $this->item->langTagForTW; ?>" data-via="<?php if($this->item->params->get('twitterUsername')) echo $this->item->params->get('twitterUsername'); ?>"><?php echo JText::_('K2_TWEET'); ?></a>
			<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
		</div>
		<?php endif; ?>

or manually adding the domain,
K2HelperUtilities::cleanHtml($this->item->title) . ' ' . $this->item->link
K2HelperUtilities::cleanHtml($this->item->title) . ' http://domain.com' . $this->item->link

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

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

  • Frederic Egersdorfer
  • Frederic Egersdorfer's Avatar
  • Offline
  • New Member
More
7 years 5 months ago #162489 by Frederic Egersdorfer
Replied by Frederic Egersdorfer on topic K2 item social sharing - link problem
Hi. I'm having a similar issue with this. Except it throws out an extra forward slash between the .co.za/ and the index.php... //index.php/...

eg. www.undergroundpress.co.za//index.php/component/k2/item/390-iheartknysna-music-festival-25-june-2017

This is becoming an issue and I don't know which files to look at.

I even added the AddThis.com social share icon to the site and it seems to do the same thing.

Any advice here on which files I should look for and what I can do to rectify this?

Thank for your time.

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

  • Frederic Egersdorfer
  • Frederic Egersdorfer's Avatar
  • Offline
  • New Member
More
7 years 5 months ago - 7 years 5 months ago #162492 by Frederic Egersdorfer
Replied by Frederic Egersdorfer on topic K2 item social sharing - link problem
I managed to sort out my issue.
It was a plugin setting in the backend that was the naughty culprit.

Joomla's "System SEF" was set as, www.mydomain.co.za/ instead it should have been set as www.mydomain.co.za (without the forward slash at the end).

This was conflicting with the twitter share url.

Yay!
Sorted, solved and this novice grows up a little today.
Fred.
Last edit: 7 years 5 months ago by Frederic Egersdorfer. Reason: incorrect spelling

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 5 months ago #162496 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 item social sharing - link problem
Nice to hear that you sorted it out Fred :)

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