Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2018-04-05 10:49:01
- masa
- Member
- From: North Wales, UK
- Registered: 2005-11-25
- Posts: 1,095
Hand-code social media share buttons
I’m currently using addThis for share buttons, but I want to get rid of the cruft and cookies it adds and I want to use my own icons. I’m looking for a simple way to code these buttons manually.
I found a nice method here Create manual social media share buttons but it relies on wordpress specific functions:
$url = urlencode( get_permalink() );
$img = urlencode( genesis_get_image( array( 'format' => 'url' ) ) );
$title = urlencode( get_the_title() );
I guess these could be done natively in PHP, but I don’t know any PHP.
I’d be very grateful for any help.
Offline
Re: Hand-code social media share buttons
Which social media channels specifically do you want to allow?
There’s many ways to achieve this, but the simplest would probably be the pat_article_social Textpattern plugin.
Offline
Re: Hand-code social media share buttons
Offline
#4 2018-04-05 13:42:40
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,477
Re: Hand-code social media share buttons
A simple method, you can style it any way you want:
<a class="share-facebook" href="https://www.facebook.com/sharer/sharer.php?u=https://your-domain.com" title="Title text"><span>Facebook</span></a>
<a class="share-twitter" href="https://twitter.com/intent/tweet?text=predefined%20text&url=https://your-domain.com" title="Title text"><span>Twitter</span></a>
Offline
Re: Hand-code social media share buttons
masa wrote #310647:
I guess these could be done natively in PHP, but I don’t know any PHP.
That is one of the advantages that Textpattern has always had over WordPress: You don’t need to know any PHP. This is the same block of code minus all the extra stuff that WP requires.
<a href="http://www.facebook.com/sharer/sharer.php?u=<txp:permlink />&t=<txp:title />" class="share-button facebook" target="_blank">Share on Facebook</a>
<a href="http://www.twitter.com/intent/tweet?url=<txp:permlink />&text=<txp:title />" class="share-button twitter" target="_blank">Tweet Me!</a>
<a href="http://pinterest.com/pin/create/button/?url=<txp:permlink />&media=<txp:image_url id='<txp:custom_field name="article_image" />' />&description=<txp:title />" class="share-button pinterest" target="_blank">Pinterest</a>
<a href="http://plus.google.com/share?url=<txp:permlink />" class="share-button google" target="_blank">Google+</a>
<a href="http://www.linkedin.com/shareArticle?mini=true&url=<txp:permlink />" class="share-button linkedin" target="_blank">LinkedIn</a>
<a href="http://www.reddit.com/submit?url=<txp:permlink />" class="share-button reddit" target="_blank">Reddit</a>
Offline
#6 2018-04-11 11:38:20
- masa
- Member
- From: North Wales, UK
- Registered: 2005-11-25
- Posts: 1,095
Re: Hand-code social media share buttons
Great, thanks everyone for all the replies!
That is one of the advantages that Textpattern has always had over WordPress: You don’t need to know any PHP. This is the same block of code minus all the extra stuff that WP requires.
Yes, I remembered that :)
I think I’ll go with Michael’s solution as it’s short and very “Textpattern-ish”.
Offline
Re: Hand-code social media share buttons
Just adding to this, that Michael’s (edit: and GugUser’s) solution seems to be the only one, that doesn’t necessarily support the data mining done by all social media companies (survival strategy) – or does it still?
Last edited by jayrope (2018-04-23 21:27:45)
A hole turned upside down is a dome, when there’s also gravity.
Offline
Re: Hand-code social media share buttons
jayrope wrote #311339:
or does it still?
Back in 1997 or so, a friend of mine and I put together what we considered at the time a massive list of Young Adult Literature Resources you could find on the Web. I put it online and submitted it to all the major search engines. And a few weeks later, it was very exciting that when you did a search the page would show up.
Flash forward to the early days of Blogging and it was simply amazing by 2002/2003 that you could post something online, have it spidered, indexed, and be able to search for it within a few hours.
Putting these buttons on a page is certainly a way to bring the content to the attention of the various sites. Is that data-mining? Possibly. I guess it depends on your point of view.
Offline
Re: Hand-code social media share buttons
Michael, hmm, it seems easier (and doesn’t involve visitor tracking) to simply submit a URL to various search engines and then let those do their work.
A hole turned upside down is a dome, when there’s also gravity.
Offline
Re: Hand-code social media share buttons
Revisiting this thread so as to contribute an alternative code, based on Michael’s but using more txp tags.
<a href="http://www.facebook.com/sharer/sharer.php?u=<txp:permlink />&t=<txp:title />: <txp:meta_description format="" />" class="share-button facebook" target="_blank">Share on Facebook</a>
<a href="http://www.twitter.com/intent/tweet?url=<txp:permlink />&text=<txp:title />: <txp:meta_description format="" />" class="share-button twitter" target="_blank">Tweet Me!</a>
You get my drift….
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Hand-code social media share buttons
jayrope wrote #312221:
Michael, hmm, it seems easier (and doesn’t involve visitor tracking) to simply submit a URL to various search engines and then let those do their work.
In my redesign of Patetech, I figured out the easiest way in 4.7 to keep myself from being tracked so I don’t throw off the stats.
<txp:if_logged_in not>
<txp:output_form form="google-global-site-tag" />
<txp:output_form form="google-auto-ad-code" />
</txp:if_logged_in>
One of the things I am working on now is figuring out how to give site visitors the ability to do the same thing.
Offline
Re: Hand-code social media share buttons
michaelkpate wrote #312229:
In my redesign of Patetech, I figured out the easiest way in 4.7 to keep myself from being tracked so I don’t throw off the stats.
<txp:if_logged_in not>...
p. Nice omission of the else
statement!!!
One of the things I am working on now is figuring out how to give site visitors the ability to do the same thing.
Would oui_cookie be able to do that?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline