- Posts: 8
COMMUNITY FORUM
[SOLVED]Social Buttons do not show on frontpage
- GSR Admin
- Topic Author
- Offline
- New Member
Less
More
10 years 9 months ago - 10 years 8 months ago #122754
by GSR Admin
[SOLVED]Social Buttons do not show on frontpage was created by GSR Admin
I have found a few people with this same issue but no replies or fixes. Buttons appear fine when an article is open but not on the frontpage
www.gwinnettsportsreport.com
www.gwinnettsportsreport.com
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 9 months ago #122755
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Re: Social Buttons do not show on frontpage
You have to override your K2 template and copy the social button's code (without the PHP stuff just the buttons) to the category_item.php file as well.
This post will assist you in finding the files you need to edit: getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
This post will assist you in finding the files you need to edit: getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- GSR Admin
- Topic Author
- Offline
- New Member
Less
More
- Posts: 8
10 years 9 months ago #122756
by GSR Admin
Replied by GSR Admin on topic Re: Social Buttons do not show on frontpage
Thank you for your advice. I have created a few k2 templates and selected one for the home page. The document link you supplied and the video tutorials explain the process very well.
Now the editing of the php files is another story. I copied what I though was the social button info from item.php in my new home template:
<?php if($this->item->params->get('itemTwitterButton',1) || $this->item->params->get('itemFacebookButton',1) || $this->item->params->get('itemGooglePlusOneButton',1)): ?>
<!-- Social sharing -->
<div class="itemSocialSharing">
<?php if($this->item->params->get('itemTwitterButton',1)): ?>
<!-- Twitter Button -->
<div class="itemTwitterButton">
<a href="twitter.com/share" class="twitter-share-button" data-count="horizontal"item->params->get('twitterUsername')): ?> data-via="item->params->get('twitterUsername'); ?>">
<?php echo JText::_('K2_TWEET'); ?>
</a>
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
</div>
<?php endif; ?>
<?php if($this->item->params->get('itemFacebookButton',1)): ?>
<!-- Facebook Button -->
<div class="itemFacebookButton">
<div id="fb-root"></div>
<script type="text/javascript">
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-like" data-send="false" data-width="200" data-show-faces="true"></div>
</div>
<?php endif; ?>
<?php if($this->item->params->get('itemGooglePlusOneButton',1)): ?>
<!-- Google +1 Button -->
<div class="itemGooglePlusOneButton">
<g:plusone annotation="inline" width="120"></g:plusone>
<script type="text/javascript">
(function() {
window.___gcfg = {lang: 'en'}; // Define button default language here
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</div>
<?php endif; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
and pasted in category_item.php, put the new category_item.php but still cannot get the social buttons to display on the home page. Im sure im missing something simple and appreciate any help.
thanks
Now the editing of the php files is another story. I copied what I though was the social button info from item.php in my new home template:
<?php if($this->item->params->get('itemTwitterButton',1) || $this->item->params->get('itemFacebookButton',1) || $this->item->params->get('itemGooglePlusOneButton',1)): ?>
<!-- Social sharing -->
<div class="itemSocialSharing">
<?php if($this->item->params->get('itemTwitterButton',1)): ?>
<!-- Twitter Button -->
<div class="itemTwitterButton">
<a href="twitter.com/share" class="twitter-share-button" data-count="horizontal"item->params->get('twitterUsername')): ?> data-via="item->params->get('twitterUsername'); ?>">
<?php echo JText::_('K2_TWEET'); ?>
</a>
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
</div>
<?php endif; ?>
<?php if($this->item->params->get('itemFacebookButton',1)): ?>
<!-- Facebook Button -->
<div class="itemFacebookButton">
<div id="fb-root"></div>
<script type="text/javascript">
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-like" data-send="false" data-width="200" data-show-faces="true"></div>
</div>
<?php endif; ?>
<?php if($this->item->params->get('itemGooglePlusOneButton',1)): ?>
<!-- Google +1 Button -->
<div class="itemGooglePlusOneButton">
<g:plusone annotation="inline" width="120"></g:plusone>
<script type="text/javascript">
(function() {
window.___gcfg = {lang: 'en'}; // Define button default language here
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</div>
<?php endif; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
and pasted in category_item.php, put the new category_item.php but still cannot get the social buttons to display on the home page. Im sure im missing something simple and appreciate any help.
thanks
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 8 months ago #122757
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Re: Social Buttons do not show on frontpage
You need to remove the php if statements. They will always return false and buttons will not appear.
Eg. thisand of course the trailing
have to go
Eg. this
<?php if($this->item->params->get('itemGooglePlusOneButton',1)): ?>
<?php endif; ?>
have to go
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- GSR Admin
- Topic Author
- Offline
- New Member
Less
More
- Posts: 8
10 years 8 months ago #122758
by GSR Admin
Replied by GSR Admin on topic Re: Social Buttons do not show on frontpage
Thank you for your advice Krikor, as you have probably already realized im not very good with PHP yet. I have been unable to get the social buttons to display on the homepage.
Please Log in or Create an account to join the conversation.
- Yiota
- Visitor
10 years 8 months ago #122759
by Yiota
Replied by Yiota on topic Re: Social Buttons do not show on frontpage
Your homepage consists of a mod_k2_content, not the component itself. The changes @krikor has mentioned apply in the listing of a category, not the module.
To add social buttons in the module you need to create a template override for the module. Just copy the Default folder located in modules/mod_k2_content/tmpl/ in templates/your_template/html/mod_k2_content/.
If you already use template overrides for the module ignore the previous step.
Open default.php file and add the following code where you want the social buttons to appear.
Don't forget to replace the data-via="_add_your_twitter_username_" with your twitter username.
To add social buttons in the module you need to create a template override for the module. Just copy the Default folder located in modules/mod_k2_content/tmpl/ in templates/your_template/html/mod_k2_content/.
If you already use template overrides for the module ignore the previous step.
Open default.php file and add the following code where you want the social buttons to appear.
<!-- Social sharing -->
<div class="itemSocialSharing">
<!-- Twitter Button -->
<div class="itemTwitterButton">
<a href="https://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="_add_your_twitter_username_">
<?php echo JText::_('K2_TWEET'); ?>
</a>
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
</div>
<!-- Facebook Button -->
<div class="itemFacebookButton">
<div id="fb-root"></div>
<script type="text/javascript">
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-like" data-send="false" data-width="200" data-show-faces="true"></div>
</div>
<!-- Google +1 Button -->
<div class="itemGooglePlusOneButton">
<g:plusone annotation="inline" width="120"></g:plusone>
<script type="text/javascript">
(function() {
window.___gcfg = {lang: 'en'}; // Define button default language here
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</div>
<div class="clr"></div>
</div>
Don't forget to replace the data-via="_add_your_twitter_username_" with your twitter username.
Please Log in or Create an account to join the conversation.
- GSR Admin
- Topic Author
- Offline
- New Member
Less
More
- Posts: 8
10 years 8 months ago #122760
by GSR Admin
Replied by GSR Admin on topic Re: Social Buttons do not show on frontpage
Yiota,
That worked great!
Thank you
That worked great!
Thank you
Please Log in or Create an account to join the conversation.