How add a sharing button on Static pages ?

This is the right place to report general bugs, make suggestions or ask for help.
Post Reply
Panther
Posts: 52
Joined: Mon Aug 12, 2019 11:05 pm

How add a sharing button on Static pages ?

Post by Panther » Fri Feb 19, 2021 6:43 pm

If I want to add a sharing button (like Facebook or Twitter, Whatsapp, etc....) on entries (articles) I have to add a code like this on entry-default.tpl:

<a href="http://www.facebook.com/sharer.php?u={$ ... :the_title}" target="_blank"><img src="/Immagini/facebook.png" border="0" alt="Facebook" width="42" height="42"></a>

<a href="http://twitter.com/share?text={$subject ... :post_link}" target="_blank"><img src="/Immagini/twitter.png" border="0" alt="Twitter" width="42" height="42" ></a>

But adding this on Static pages this doesn't work, ad ex. Facebook reports this error:
href should represent a valid URL

and Twitter (a white page).

On Static pages what type of code I have to add ? It have to be different from ({$id|link:post_link}&title={$subject|tag:the_title}") ?

P.S.
Obviously using sharethis or addthis or addtoany buttons works, but I'd like to use my own sharing buttons.

Thank you

Tongara
Posts: 77
Joined: Wed Jan 22, 2020 11:09 am
Location: Birmingham, UK
Contact:

Re: How add a sharing button on Static pages ?

Post by Tongara » Sat Feb 20, 2021 2:19 am

On the plugin you made last year, I did add a thing on how to make it work on static pages. The same change will work here.

Please see this post: viewtopic.php?f=4&t=144&start=10#p453

Lubomír Ludvík
Posts: 44
Joined: Wed Feb 20, 2019 7:44 pm
Location: Rouchovany
Contact:

Re: How add a sharing button on Static pages ?

Post by Lubomír Ludvík » Sat Feb 20, 2021 3:50 pm

Add "Share this:" to template with Awesome font
View this source and copy with .css link to entry-default.tpl

Panther
Posts: 52
Joined: Mon Aug 12, 2019 11:05 pm

Re: How add a sharing button on Static pages ?

Post by Panther » Sat Feb 20, 2021 4:26 pm

Tongara wrote: Sat Feb 20, 2021 2:19 am On the plugin you made last year, I did add a thing on how to make it work on static pages. The same change will work here.

Please see this post: viewtopic.php?f=4&t=144&start=10#p453
Hi, I have tried to modify in:

<a href="http://www.facebook.com/sharer.php?u={$ ... :the_title}" target="_blank"><img src="/Immagini/facebook.png" border="0" alt="Facebook" width="36" height="36"></a>

Then going of mouse on facebook button appears this:
http://www.facebook.com/sharer.php?u={$ ... :the_title}

and Facebook window reports error:
href should represent a valid URL


at contrary of articles where cliking of facebook button appears:
http://www.facebook.com/sharer.php?u=ht ... 0displaced


On Twitter button
<a href="http://twitter.com/share?text={$subject ... :page_link}" target="_blank"><img src="/Immagini/twitter.png" border="0" alt="Twitter" width="36" height="36" ></a>

the page appears completly white

Lubomír Ludvík
Posts: 44
Joined: Wed Feb 20, 2019 7:44 pm
Location: Rouchovany
Contact:

Re: How add a sharing button on Static pages ?

Post by Lubomír Ludvík » Sat Feb 20, 2021 5:38 pm

replace page_link with post_link

Tongara
Posts: 77
Joined: Wed Jan 22, 2020 11:09 am
Location: Birmingham, UK
Contact:

Re: How add a sharing button on Static pages ?

Post by Tongara » Sat Feb 20, 2021 6:21 pm

Panther wrote: Sat Feb 20, 2021 4:26 pmHi, I have tried to modify in:

<a href="http://www.facebook.com/sharer.php?u={$ ... :the_title}" target="_blank"><img src="/Immagini/facebook.png" border="0" alt="Facebook" width="36" height="36"></a>

Then going of mouse on facebook button appears this:
http://www.facebook.com/sharer.php?u={$ ... :the_title}

and Facebook window reports error:
href should represent a valid URL


at contrary of articles where cliking of facebook button appears:
http://www.facebook.com/sharer.php?u=ht ... 0displaced


On Twitter button
<a href="http://twitter.com/share?text={$subject ... :page_link}" target="_blank"><img src="/Immagini/twitter.png" border="0" alt="Twitter" width="36" height="36" ></a>

the page appears completly white
Very strange!

My code is like so (It uses fontawesome, but ignore that, as it';s not the point):

Code: Select all

 <a href="http://www.facebook.com/sharer.php?u={$id|link:page_link}&title={$subject|tag:the_title}" target="_blank">
<i class="fab fa-facebook-square fa-lg"></i></a>
<a href="http://twitter.com/share?text={$subject|tag:the_title}&url={$id|link:page_link}" target="_blank">
<i class="fab fa-twitter-square fa-lg"></i></a>
<a href="whatsapp://send?text={$subject|tag:the_title} {$id|link:page_link}" data-action="share/whatsapp/share" target="_blank">
<i class="fab fa-whatsapp-square fa-lg"></i></a>
<a href="fb-messenger://share/?link={$id|link:page_link}&app_id=IDHERE" target="_blank">
<i class="fab fa-facebook-messenger fa-lg"></i></a>
<a href="http://pinterest.com/pin/create/link/?url={$id|link:page_link}&description={$subject|tag:the_title}" count-layout="horizontal" target="_blank">
<i class="fab fa-pinterest-square fa-lg"></i></a>
<a href="http://www.tumblr.com/share/link?url={$id|link:page_link}" target="_blank">
<i class="fab fa-tumblr-square fa-lg"></i></a>
<a href="https://reddit.com/submit?url={$id|link:page_link}&title={$subject|tag:the_title}" target="_blank">
<i class="fab fa-reddit-square fa-lg"></i></a>
<a href="mailto:?subject={$subject|tag:the_title}&amp;body={$id|link:page_link}" title="{$subject|tag:the_title}">
<i class="fas fa-envelope-square fa-lg"></i></a>
Check if yours matches up to that. I've tested mine again just now and it 100% works. I've copied this code directly from my static.tpl.
Lubomír Ludvík wrote: Sat Feb 20, 2021 5:38 pm replace page_link with post_link
On static pages, page_link is appropriate. post_link is used for blog posts, as shown here:

Code: Select all

<a href="http://www.facebook.com/sharer.php?u={$id|link:post_link}&title={$subject|tag:the_title}" target="_blank">
<i class="fab fa-facebook-square fa-lg"></i></a>
<a href="http://twitter.com/share?text={$subject|tag:the_title}&url={$id|link:post_link}" target="_blank">
<i class="fab fa-twitter-square fa-lg"></i></a>
<a href="whatsapp://send?text={$subject|tag:the_title} {$id|link:post_link}" data-action="share/whatsapp/share" target="_blank">
<i class="fab fa-whatsapp-square fa-lg"></i></a>
<a href="fb-messenger://share/?link={$id|link:post_link}&app_id=IDHERE" target="_blank">
<i class="fab fa-facebook-messenger fa-lg"></i></a>
<a href="http://pinterest.com/pin/create/link/?url={$id|link:post_link}&description={$subject|tag:the_title}" count-layout="horizontal" target="_blank">
<i class="fab fa-pinterest-square fa-lg"></i></a>
<a href="http://www.tumblr.com/share/link?url={$id|link:post_link}" target="_blank">
<i class="fab fa-tumblr-square fa-lg"></i></a>
<a href="https://reddit.com/submit?url={$id|link:post_link}&title={$subject|tag:the_title}" target="_blank">
<i class="fab fa-reddit-square fa-lg"></i></a>
<a href="mailto:?subject={$subject|tag:the_title}&amp;body={$id|link:post_link}" title="{$subject|tag:the_title}">
<i class="fas fa-envelope-square fa-lg"></i></a>

Panther
Posts: 52
Joined: Mon Aug 12, 2019 11:05 pm

Re: How add a sharing button on Static pages ?

Post by Panther » Sat Feb 20, 2021 7:43 pm

Now it works, this is because I didn't use static.tpl (as you), but I used another file.
I've read again your post to understand where was my error.
Thank you very much to all.

Tongara
Posts: 77
Joined: Wed Jan 22, 2020 11:09 am
Location: Birmingham, UK
Contact:

Re: How add a sharing button on Static pages ?

Post by Tongara » Sat Feb 20, 2021 8:43 pm

Ah, glad you got it working! :)

Panther
Posts: 52
Joined: Mon Aug 12, 2019 11:05 pm

Re: How add a sharing button on Static pages ?

Post by Panther » Sat Feb 20, 2021 9:18 pm

If this can help you, this works better

http://www.facebook.com/sharer/sharer.php (with this every page is shared well)

than this

http://www.facebook.com/sharer.php

At the end I use this code:

Code: Select all

<a href="http://www.facebook.com/sharer/sharer.php?u={$id|link:page_link}&title={$subject|tag:the_title}" target="_blank"><img src="/Immagini/facebook.png" border="0" alt="Facebook" width="36" height="36"></a>

Tongara
Posts: 77
Joined: Wed Jan 22, 2020 11:09 am
Location: Birmingham, UK
Contact:

Re: How add a sharing button on Static pages ?

Post by Tongara » Sun Feb 21, 2021 2:06 pm

Panther wrote: Sat Feb 20, 2021 9:18 pm If this can help you, this works better

http://www.facebook.com/sharer/sharer.php (with this every page is shared well)

than this

http://www.facebook.com/sharer.php

At the end I use this code:

Code: Select all

<a href="http://www.facebook.com/sharer/sharer.php?u={$id|link:page_link}&title={$subject|tag:the_title}" target="_blank"><img src="/Immagini/facebook.png" border="0" alt="Facebook" width="36" height="36"></a>
Oh nice, I'm always up for using something better if it turns up, so I appreciate it. I have now updated my code on my blog.

Glad we could help one another! haha

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests