Share page on social networks - droplets

macsmet

Hi Tez,

Thanks, I didn't know that.

greetings,

MacSmet

Tez Oner

Hey MacSmet,

QuoteIt doesn't copy the news message into the facebook sharer.

Thats been depreciated by FB anyway because of the possibility to spam.

Cheerz,

Tez Oner
Tez | VA-MDS / MMO | communications
--------------------------------------------
info@va-mds.com / [url="http://va-mds.com"]http://va-mds.com[/url]

macsmet

Hi dbs,

Thanks for your reply.
It works now. But it only gives me the website title and page URL.
It doesn't copy the news message into the facebook sharer.
Bummer!

greetings,

MacSmet

dbs

Hi, you mean stefeks colored code?
This forum has changed the codes a little bit.
This:
$sql   = "SELECT `link` AS 'link',
Should looks like this:
$sql   = "SELECT `link` AS 'link',
and so on.
[url="https://onkel-franky.de"]https://onkel-franky.de[/url]

macsmet

Hi there,

i just discovered this topic.
I can't get this to work.
When I make a new droplet (copy/pasting code) from Stefek's code it says the code is invalid.

Anyone else having this?
I know this is an old topic but I am looking for an easy way to use Twitter and Facebook with news.

Thanks!

Greetings,

MacSmet


DarkViper

Quote from: golem on September 22, 2011, 08:10:44 PM
No, didn't work.
When I change this to `post_id`='$post_id'"; the facebook botton does not appear. ???

$post_id  is a variable from global scope, so inside a droplet you must import( global $post_id; ) it or use $GLOBALS['post_id'].
The constant 'POST_ID' is never available from WB2.8.2. (see post-access files)
[url=http://www.youtube.com/watch?v=tmzDAz6ZvFQ]Der blaue Planet[/url] - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen[br]
[i]"You have to take the men as they are... but you can not leave them like that !" :-P [/i]
[i]Das tägliche Stoßgebet: [b]Oh Herr, wirf Hirn vom Himmel ![/b][/i]

Bug


crnogorac081

wierd,

if you want you can send me a temp admin password on pm to take a look..

cheers
Web developer

golem

No, didn't work.

Even when I delete this:

// query for standard pages
$sql   = "SELECT `link` AS 'link', `page_title` AS 'title', `description` AS 'teaser' FROM `".TABLE_PREFIX."pages` WHERE `page_id` = ".PAGE_ID;

// query for news posts
if(defined('post_id')){

   $sql = "SELECT `link` AS 'link', `title` AS 'title', `content_short` AS 'teaser' FROM `".TABLE_PREFIX."mod_news_posts` WHERE `post_id`=".POST_ID;
}

the result is: http://...../pages.php/ with an 404 error

When I change this to `post_id`='$post_id'"; the facebook botton does not appear. ???

crnogorac081

Hi,

try to replace `post_id`=".POST_ID; with `post_id`='$post_id'";

cheers
Web developer

golem

Hi,

unfortuantly it doensn't work on my news-site. I am using WB 2.8.2 Rev. 1506. Is there s.th. to change on this:

// query for news posts
if(defined('POST_ID')){
$sql = "SELECT `link` AS 'link', `title` AS 'title', `content_short` AS 'teaser' FROM `".TABLE_PREFIX."mod_news_posts` WHERE `post_id`=".POST_ID;
}


I get the share button, but only my news.php site is visible as link. I tried to use this within my short and my long descrition. Both links go back to my news overview. Even the title is the one of the news site.

Any idea?

Thanks.

dbs

#18
Nice Droplet Stefek,

but in wb2.8.2 or 2.8.1 it seems the content_short will not displayed.

works well, thx.


dbs
[url="https://onkel-franky.de"]https://onkel-franky.de[/url]

Stefek

Hello,

maybe someone else may help you better, as I do not have any twitter/facebook etc. account.
I don't know the mechanics of those services.
But it should be possible with some small adjustments of the Droplet.

Regards,
Stefek
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

firefoxfx

Hey Stefek,

Thanks for the facebook droplet, it works very good.
Is it also possible to make the same for twitter?

I tried to adjust the code but it doesn't add the news item title to the tweet, only the site name and the page title.

Thanks in advance.

Firefoxfx

Stefek

Hello James,

thanks for letting me know, as I myself got no facebook account I couldn't test it.
I'm glad it works.

Regards,
Stefek
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

sky writer

Stefek,
This solution worked absolutely perfectly.  Thank you so much for your time and kindness.
Cheers!

Stefek

Hello Sky Writer,

I created the following one on the fly.


<?php
//$icon_url = WB_URL.MEDIA_DIRECTORY.'/facebook.png';
$icon_url "http://profile.ak.fbcdn.net/hprofile-ak-snc4/174597_20531316728_2866555_q.jpg";

$template = <<<_TEMPLATE_END

<span class="facebook-share">
<a target="_blank" title="facebook: Share This Page With Your Friends" href="http://www.facebook.com/sharer.php?u=[LINK]%2F&amp;t=[TITLE] - [TEASER]">
<img alt="Facebook Share" width="16" height="16" border="0" src="
$icon_url" />
facebook: Share Page</a>
</span>

_TEMPLATE_END;


// query for standard pages
$sql "SELECT `link` AS 'link', `page_title` AS 'title', `description` AS 'teaser' FROM `".TABLE_PREFIX."pages` WHERE `page_id` = ".PAGE_ID;

// query for news posts
if(defined('POST_ID')){
$sql "SELECT `link` AS 'link', `title` AS 'title', `content_short` AS 'teaser' FROM `".TABLE_PREFIX."mod_news_posts` WHERE `post_id`=".POST_ID;
}

global 
$database;
$results $database->query($sql);
if (
$results->numRows() > 0) {
    
$row $results->fetchRow();

$placeholder = array(
'[LINK]'  => WB_URL.PAGES_DIRECTORY.$row['link'].PAGE_EXTENSION,
'[TITLE]' => $row['title'],
'[TEASER]'  => $row['teaser'],
);

$ret_val str_replace(array_keys($placeholder), array_values($placeholder), $template);

return (isset(
$ret_val)) ? $ret_val : (TRUE);

This one can be used both: on NEWS Posts and on regular pages.

Note: for regular Pages you will need to fill the Page Description in Page Settings, otherwise you'll get an empty string.
For News Pages the `content_short` field is fetched from DB.

What to do:
replace the $icon_url string in the droplet.
Adjust the "template" between ....

$template =<<<_TEMPLATE_END

..... your template

_TEMPLATE_END;

... to your needs.

Should work fine.

Regards,
Stefek
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Stefek

Hello,

do you want to have the [SHARE BUTTON] only in the news posts (Long Post)?
Or is this droplet and button used only on another places?

And if only on the News Posts, which data exactly you want to submitt with the button?

Lets assume this is the code you have now:
<h1>
<a target="_blank" title="facebook: Share This Page With Your Friends" href="http://www.facebook.com/sharer.php?u='.$page.'%2F&amp;t=' .PAGE_TITLE.' - '.PAGE_DESCRIPTION.'">
<img alt="Facebook Favicon" width="16" height="16" border="0" src="'.WB_URL.MEDIA_DIRECTORY.'/social/facebook.png" />
facebook: Share Page</a>
</h1>


We have some output to be replaced:
$page = this should be the actual URL to the Post, right?
PAGE_TITLE = the actual title of the Post, right?
PAGE_DESCRIPTION = would you like to have the "short description" of the news post or a "substring" of the "full description"?

(note that there is no actual PAGE_DESCRIPTION set for the news items itself)

Regards,
Stefek
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

sky writer

I have used this droplet to Share pages on Facebook for some time, and I like it, except that I can't figure something out.

I have a "Portfolio" page which consists of one NEWS section.  If I click the Share link on a news "post" page, the LINK, "Page_Title" and "PAGE_DESCRIPTION" from the Portfolio page is used, not the News Post Page.  I would like to share the actual page that is being viewed.  Is there a way to change the code to allow for this functionality?

//:
//:
global $database, $admin;
$sql = "SELECT link FROM ".TABLE_PREFIX."pages where page_id=".PAGE_ID;
$results = $database->query($sql);
if ($results && $results->numRows() > 0) {
    $row = $results->fetchRow();
$page = page_link($row['link']);
}


return '<h1>&nbsp<a target="_blank" title="facebook: Share This Page With Your Friends" href="http://www.facebook.com/sharer.php?u='.$page.'%2F&amp;t=' .PAGE_TITLE.' - '.PAGE_DESCRIPTION.'"><img alt="Facebook Favicon" width="16" height="16" border="0" src="'.WB_URL.MEDIA_DIRECTORY.'/social/facebook.png" />facebook: Share Page</a></h1>';



robin

nice work! excellent idea!
:-D
Cheers, Robin.

snark

find attached droplets to share your page with social networks

it lets visitors share a link to the page on their favorite social network, leaving the name of the page, the page description + the optional tekst that the visitor can add to the share

for now I did the droplets for:


  • ask
  • delicious
  • digg
  • ekudos
  • facebook
  • googlebookmarks
  • hyves
  • linkedin
  • live
  • nujij
  • twitter

[gelöscht durch Administrator]

snark

#8
okay
global $database, $admin;
$sql = "SELECT link FROM ".TABLE_PREFIX."pages WHERE `page_id` = '$page_id'";
$results = $database->query($sql);
if ($results && $results->numRows() > 0) {
    $row = $results->fetchRow();
$page = page_link($row['link']);
}

echo $page;


when I turn this into a droplet

global $database, $admin;
$sql = "SELECT link FROM ".TABLE_PREFIX."pages WHERE `page_id` = '$page_id'";
$results = $database->query($sql);
if ($results && $results->numRows() > 0) {
    $row = $results->fetchRow();
$page = page_link($row['link']);
}

return $page;


it doesn't work ... any suggestions/ corrections are welcome


kweitzel

In the DB Tabel pages is a field called link. Make an SQL with the current PAGE_ID, put the result in a variable (e.g. $link) and then build the link with WB_URL and $link ...

cheers

Klaus

snark

this is a sample of what I need to put in as code...


<a target="_blank" title="Plaats dit artikel op: Facebook" href="http://www.facebook.com/sharer.php?u=http://website.com/pages/home.php%2F&amp;t=title-of-message"><img alt="Facebook Favicon" width="16" height="16" border="0" src="http://www.website.com/media/icons/facebook.png" /></a>


can anyone tell me how to put in the url of the current page dynamically

http://website.com/pages/home.php

that way the soc media icon will produce a link to the page it is clicked from





snark

yes

like: http://www.telegraaf.nl/binnenland/6565317/__Heide_in_brand_bij_Bergen_op_Zoom__.html?sn=binnenland,buitenland

I got the script no problem.. just ripped it from a website... and it works, no worries about that

but it just makes a link to the www.website.com and not to the current page


since all links are somewhat different ( facebook, twitter, linkedin etc) I think it would be best to make a set of droplets from these individual scripts

but as said therefor the current pagelink needs to be put into the script and I just do not know how...

I will post the code to one soc network tomorrow so we can take a look at it


thanks so far