- Posts: 7
COMMUNITY FORUM
How can I place social share icon on category list
- Diogo Alberto
-
Topic Author
- Offline
- New Member
Attachment not found
Hello, how can I do that? So i can put social share links on category list... like other blogs.
See the screenshot please
King Regards
Attachment not found
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Open the item.php file and copy all the social code WITHOUT the php stuff, just the HTML and JS.
Paste the code where you want to appear in the category_item.php file. Some styling might be needed in order to align the buttons.
Now you need to manually specify a link for each social button.
For the like button add
data-href="<?php echo $this->item->link; ?>"
Full instructions and options are located here: developers.facebook.com/docs/plugins/like-button/
for twitter add
data-url="<?php echo $this->item->link; ?>"
All options are located here: Invalid consumer key/secret in configuration
Finally for G+ add
data-href="<?php echo $this->item->link; ?>"
developers.google.com/+/web/+1button/ for more options.
Please Log in or Create an account to join the conversation.
- Diogo Alberto Caixeta
-
- Offline
- New Member
- Posts: 3
Diogo Alberto wrote:
Attachment not found
Hello, how can I do that? So i can put social share links on category list... like other blogs.
See the screenshot please
King Regards
Attachment not found
thanks I will try now.
Please Log in or Create an account to join the conversation.
- Diogo Alberto Caixeta
-
- Offline
- New Member
- Posts: 3
Krikor Boghossian wrote: You need to edit your template's category_php file.
Open the item.php file and copy all the social code WITHOUT the php stuff, just the HTML and JS.
Paste the code where you want to appear in the category_item.php file. Some styling might be needed in order to align the buttons.
Now you need to manually specify a link for each social button.
For the like button adddata-href="<?php echo $this->item->link; ?>"
Full instructions and options are located here: developers.facebook.com/docs/plugins/like-button/
for twitter addto the buttons's codedata-url="<?php echo $this->item->link; ?>"
All options are located here: Invalid consumer key/secret in configuration
Finally for G+ addto the button's codedata-href="<?php echo $this->item->link; ?>"
developers.google.com/+/web/+1button/ for more options.
hello mate, thanks for the updated.. but did something wrong help me please..
with facebook all good.. but with twitter and g+ no.
GOOGLE +
<div class="g-plusone" data-annotation="inline" data-width="300" data-href="<?php echo $this->item->link; ?>"></div>
data-url="<?php echo $this->item->link; ?>" >Tweet</a>
can u help? thank you in advanced
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
- Posts: 8743
Add the following code in line 15 of your category_item.php:
$this->item->absoluteURL = JRoute::_(K2HelperRoute::getItemRoute($this->item->id.':'.$this->item->alias, $this->item->catid), true, -1);
Then in the social links code use the :
<?php echo $this->item->absoluteURL; ?>
instead of :
<?php echo $this->item->link; ?>
Please Log in or Create an account to join the conversation.
- Gorast
-
- Offline
- Premium Member
- Posts: 141
Thanks!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- marco
-
- Offline
- New Member
- Posts: 2
Could you please suggest the code to put at the beginning of user.php/tag.php in order to get the ABSOLUTE PATH?
I'm using the social link below to share on facebook the items showed on user.php/tag.php :
<a href="https://www.facebook.com/sharer.php?u=<?php echo $item->absoluteURL; ?>" target="_blank"> Facebook</a>
Rob
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
$item->link should be instead, with the domain as a prefix, since $item->absoluteURL; is not available in these views.
Please Log in or Create an account to join the conversation.