Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: share/like buttons for articles  (Read 2620 times)

adminphp

  • Full Member
  • ***
  • Karma: 3
  • Posts: 176
  • you must be a great snewser .
share/like buttons for articles
« on: March 11, 2014, 12:34:25 PM »

Hey everyone;

I hope you are fine; Ok, my website works snews 1.6 since 2008 and it a very excellent cms and light. ok; my question is simple; I want to have share/like box for articles.

Is it possible to have a box like/share of facebook and twitter and other social websites. I stress on, that the bar should include sharer button and like one. and  i have tried to create some addons for this issue, But there are some problems concerning my cms. for instance, facebook don't pick up the right image, Actually never did. I guess we should have some meta tags for image and article and description.
« Last Edit: March 11, 2014, 12:36:35 PM by adminphp »
Logged
“Fifty years of programming language research, and we end up with C++?”

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6288
  • Semantically Challenged
    • snews.ca
Re: share/like buttons for articles
« Reply #1 on: March 11, 2014, 05:14:32 PM »

Hi phpadmin:
Interesting that you would ask about this. About 4 years ago I posted a Facebook LIKE mod for both 1.6 and 1.7 ... and you had replied to the 1.6 thread on August 29, 2010.  8)

Check it out if have not done so yet. Perhaps you can modify it to display it as you like.
Facebook "Like" link - all sNews 1.6 versions
Facebook "Like" link - all sNews 1.7 versions

Facebook Developers Information on How to add a Like link.
Facebook Developers Information on How to add a Share link or button.
« Last Edit: March 11, 2014, 05:22:11 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

adminphp

  • Full Member
  • ***
  • Karma: 3
  • Posts: 176
  • you must be a great snewser .
Re: share/like buttons for articles
« Reply #2 on: March 11, 2014, 10:49:51 PM »

Hey keyrocks;

Thanks for your prompt reply; Yes I have modify it in the past so that It can compatibles with html5 and add other social websites like twitter. I understand by this code ('.$social_url.') that it has a big function her to generate url automatically without editing facebook code everyday and add the articles' links.

that's ok, But now the problem is simple as this: facebook "like" and "share" and twitter "like" button don't pick the right image for the article. how that occurs? Ok, that's a good question: you have 20 images on your site or lets take exactly just on your article, you place a like button on your site. You see others start to “like” your content but with the wrong image (I mean I see this in facebook page; people share the content but with the wrong Img that has nothing to do with the article).

so, To solve this problem there is an only one method to do so. currently, I know it works but for snews I don't know how to add the function in snews file; so that it will helps us to do the work.

alright; this code above is usually put inside the head Tag, and I beleive it does an excellent work, to force facebook to pick the right image. But, now the problem is that I have to edit my INDEX file everytime I want to share some post or like it  to be in facebook, I have to add the new image url, save, upload the file to the host, then everything is good.
Code: [Select]
<meta property="og:image" content="<URL_TO_YOUR_IMAGE>" />at the current time, when need some thing like $image_url = db('website').upload/'.$r['articleImage'].'/';
so we can have meta like this:
<meta property="og:image" content="'.$image_url.'" />[/code]
this should not work only with Uploaded images, but also images that is outside. I beleive to do so, we should create a new field in "create new article" page; to be easy to put image url for the article. sorry keyrocks alot, If i talked to much, Hhh, it's something like "I know what to do, but i don't know how". thanks In advance.
Logged
“Fifty years of programming language research, and we end up with C++?”

adminphp

  • Full Member
  • ***
  • Karma: 3
  • Posts: 176
  • you must be a great snewser .
Re: share/like buttons for articles
« Reply #3 on: March 15, 2014, 12:49:13 PM »

KEYROCKS what is your opinion about what I wrote above? I hope you can help me In this issue, actually My website doesn't contain any social website like/share button? Due to what i have just said. Thanks alot, I know you' must have not seen My comment, that's why there wasn't your reply.
Logged
“Fifty years of programming language research, and we end up with C++?”

studio

  • Newbie
  • *
  • Karma: 1
  • Posts: 18
    • My Blog sNews 1.7
Re: share/like buttons for articles
« Reply #4 on: March 15, 2014, 05:15:39 PM »

snews 1.7

1.
add [MOD] Article Image
http://snewscms.com/forum/index.php/topic,9217.0.html

2. snews.php
global / find


// Query for  / Category / subcategory / article
find
Code: [Select]
a.id AS id, title,add
Code: [Select]
a.id AS id, title, a.image AS aimg,
// Two queries for / Category / subcategory  /  OR   / Category / article
find
Code: [Select]
a.id AS id, title,add
Code: [Select]
a.id AS id, title, a.image AS aimg,


Code: [Select]
if(!empty($R['title'])) $_TITLE = $R['title'];add after
Code: [Select]
if(!empty($R['aimg'])) $_IMAGE = $R['aimg'];
3.
in snews.php
function title()

add
Code: [Select]
$cano = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$cano_array = array('#c_[^/]+/#', '#p_1/#');
$cano = preg_replace($cano_array, '', $cano);

Code: [Select]
echo '
<meta property="og:url" content="'.$cano.'" />
<meta property="og:title" content="'.$title.'" />
<meta property="og:description" content="'.(!empty($_DESCR) ? $_DESCR : s('website_description')).'" />
';

Code: [Select]
if ($_IMAGE) {
echo '<meta property="og:image" content="'._SITE.'foto/'.$_IMAGE.'" />';
} else {
echo '<meta property="og:image" content="'._SITE.'foto/default.jpg" />';
}

test
http://www.rafal.muko.pl/zycie-z-pasja/bornholm/
« Last Edit: March 15, 2014, 06:48:36 PM by studio »
Logged
My sNews 1.7 only polish

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6288
  • Semantically Challenged
    • snews.ca
Re: share/like buttons for articles
« Reply #5 on: March 15, 2014, 06:22:17 PM »

KEYROCKS what is your opinion about what I wrote above? I hope you can help me In this issue, actually My website doesn't contain any social website like/share button? Due to what i have just said. Thanks alot, I know you' must have not seen My comment, that's why there wasn't your reply.

I did see your other post but I did not have an opinion to share with you, as I have not had time to work on this lately. But Studio has ofered his mod solution for sNews 1.7 - perhaps that will help you.  :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

adminphp

  • Full Member
  • ***
  • Karma: 3
  • Posts: 176
  • you must be a great snewser .
Re: share/like buttons for articles
« Reply #6 on: March 15, 2014, 06:58:12 PM »

Hi Keyrocks, studio;

Yes keyrocks I understand The time issue, it's ok. For my friend Studio, I think this MOD doesn't compatible with snews 1.6, If not Please tell just how to do it; I can spend sometime with it, to turn it to work with 1.6. I am stuck, while I have dreams about my snews. By the way, the test page work fine, That's how I want to make it for mine.thanks everyone. I beleive that The only thing That it's possible to stuck In is [MOD] Article Image.
« Last Edit: March 15, 2014, 07:00:54 PM by adminphp »
Logged
“Fifty years of programming language research, and we end up with C++?”

studio

  • Newbie
  • *
  • Karma: 1
  • Posts: 18
    • My Blog sNews 1.7
Re: share/like buttons for articles
« Reply #7 on: March 15, 2014, 08:24:17 PM »

snews 1.6/fast :)

// TITLE - no change from 1.5.31
Code: [Select]
function title() {
echo '<base href="'.db('website').'" />';
$categorySEF = get_id('category'); $articleSEF = get_id('article');
$categoryName = retrieve('name', 'categories', 'seftitle', $categorySEF);
$articleTitle = retrieve('title', 'articles', 'seftitle', $articleSEF);
if (!empty($articleTitle)) {$title = $articleTitle.' - ';}
if (!empty($categoryName)) {$title .= $categoryName.' - ';}
$title .= s('website_title');
echo '<title>'.$title.'</title>';
echo '<meta http-equiv="Content-Type" content="text/html; charset='.s('charset').'" />';
if (!empty($articleSEF)) {
$query = "SELECT * FROM ".db(prefix)."articles WHERE seftitle = '$articleSEF'";
$result = mysql_query($query);
while ($r = mysql_fetch_array($result)) {$dmeta = $r['description_meta']; $kmeta = $r['keywords_meta'];}
}
echo '<meta name="description" content="'.(!empty($dmeta) ? $dmeta : s('website_description')).'" />';
echo '<meta name="keywords" content="'.(!empty($kmeta) ? $kmeta : s('website_keywords')).'" />';
//add studio
$ogimage = explode(",", $kmeta);
if (empty($ogimage[0])) {
$ogimage[0] = 'default';
}
$cano = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$cano_array = array('#c_[^/]+/#', '#p_1/#');
$cano = preg_replace($cano_array, '', $cano);
echo '<meta property="og:url" content="'.$cano.'" />
<meta property="og:title" content="'.$title.'" />
<meta property="og:description" content="'.(!empty($dmeta) ? $dmeta : s('website_description')).'" />
<meta property="og:image" content="'.db('website').'upload/foto/'.$ogimage[0].'.jpg" />';
//end add studio
if ($_SESSION[db('website').'Logged_In'] == token()) {js();}
}

first key in meta
one, twoo, three
one.jpg

none key
default.jpg
« Last Edit: March 16, 2014, 02:34:09 PM by studio »
Logged
My sNews 1.7 only polish

adminphp

  • Full Member
  • ***
  • Karma: 3
  • Posts: 176
  • you must be a great snewser .
Re: share/like buttons for articles
« Reply #8 on: March 16, 2014, 01:54:21 PM »

Hi studio, Thanks for the reply. I have few question, The article image MOD doesn't seem to work with me, I tried to add the two rooms In db but A problem occurs, i think because of the "collate" that was mentioned by fred K. i Dont ' know how to solve this, moreover, the last codes you gave, I don't know where to put them, since you have not given more explanation about it.

Maybe if you don't want to explain it more just for me since I am the only one who wants it, You can add the mod to my snews file and in this case I provide the link where you can find my snews file called  config2011.php. thanks.


The whole story based on this MOD http://snewscms.com/forum/index.php/topic,9217.0.html As it is not working with 1.6 and usually members here, when they create some add they' don't give much importance to 1.6 .
Now I am definitely stuck, everyone shows' how to do it; But I must say I am stuck guys, Sorry I don't know from where should I begin. There must be someone who could  explain this well, Like doug, I used to understand everything he says, He usually thinks that there are members who are beginners Or have not much knowledge about PHP.  The first step I did to work this add In my snews I found a problem;  this order can't be accepted In my DB. I think because of the collate that was mentioned by fred K, but he have not said how to solve it.
Code: [Select]
ALTER TABLE  `articles` ADD  `image` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NULL
ALTER TABLE  `articles` ADD  `img_alt` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NULL
Moreover, I have a question does this Mod  work with images that are loading from other domain? as You can see above I shared my snews file, if someone please can add the whole MOD, you'll be appreciated alot. thanks.
« Last Edit: March 16, 2014, 03:50:20 PM by adminphp »
Logged
“Fifty years of programming language research, and we end up with C++?”