Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

OpenGraph modify

Asked Modified Viewed 816 times
A
Apis
A
Apis 12
  • Junior Member, joined since
  • Contributed 42 posts on the community forums.
  • Started 13 threads in the forums
  • Started this discussions
asked
Junior Member

I would like to modify the OpenGraph.php file so that the news posted on Facebook shows:

'title' => news subject
'description' => news snipet or site description
'url' => news url
'keywords' => (no change)
'image' => news image
'site_name' => (no change)
'type' => website

I tried to add the following solution to the file, but it doesn't work and generates an error:

 /**
 * @param int $newsid
 */
 public static function ogNews($newsid = 0) {
 $settings = fusion_get_settings();

 $info = [];
 $result = dbquery("SELECT news_news, news_keywords, news_subject, news_image_front_default FROM ".DB_NEWS." WHERE news_id=:newsid LIMIT 1", [':newsid' => $newsid]);
 if (dbrows($result)) {
 $data = dbarray($result);
 $info['title'] = $data['news_subject'].' - '.$settings['sitename'];
 $info['description'] = $data['news_news'];
 $info['url'] = $settings['siteurl'].'infusions/news/news_id='.$newsid;
 $info['image'] = $data['news_image_front_default'] ? $settings['siteurl'].'infusions/news/images/'.$data['news_image_front_default']';
 }

 self::setValues($info);
 }

Does anyone have an idea how to get this effect?
0 replies

4 posts

K
karrak
K
karrak 32
Van mi sosem változik..smile
  • Senior Member, joined since
  • Contributed 310 posts on the community forums.
  • Started 94 threads in the forums
  • Answered 1 question
answered
Senior Member

worth a try

 public static function ogNews($newsid = 0) {
 $settings = fusion_get_settings();
 $info = [];
 $result = dbquery("SELECT news_news, news_keywords, news_subject, news_image_front_default FROM ".DB_NEWS." WHERE news_id=:newsid LIMIT 1", [':newsid' => $newsid]);
 if (dbrows($result)) {
 $data = dbarray($result);
 $info = [
 'title' => $data['news_subject'].' - '.$settings['sitename'],
 'description' => $data['news_news'],
 'url' => $settings['siteurl'].'infusions/news/news_id='.$newsid,
 'type' => 'article';
 'image' => $data['news_image_front_default'] ? $settings['siteurl'].'infusions/news/images/'.$data['news_image_front_default'] : ''
 ];
 }
 self::setValues($info);
 }
0 replies
A
Apis
A
Apis 12
  • Junior Member, joined since
  • Contributed 42 posts on the community forums.
  • Started 13 threads in the forums
  • Started this discussions
answered
Junior Member

The code generates the error that I corrected (there was a semicolon instead of a comma).
 'type' => 'article',


Unfortunately - the code is ignored and the defaults are still loaded:
 private static function setDefaults() {
 $settings = fusion_get_settings();

 self::$data = [
 'title' => get_title(),
 'description' => str_replace("n", ' ', strip_tags(htmlspecialchars_decode($settings['description']))),
 'url' => $settings['siteurl'],
 'keywords' => $settings['keywords'],
 'image' => defined('THEME_ICON') ? THEME_ICON.'mstile-150x150.png' : $settings['siteurl'].'images/favicons/mstile-150x150.png',
 'site_name' => $settings['sitename'],
 'type' => 'website'
0 replies
K
karrak
K
karrak 32
Van mi sosem változik..smile
  • Senior Member, joined since
  • Contributed 310 posts on the community forums.
  • Started 94 threads in the forums
  • Answered 1 question
answered
Senior Member

which absolutely must go. title, description, url, keywords.

 public static function ogNews($newsid = 0) {
 $settings = fusion_get_settings();
 $info = [];
 $result = dbquery("SELECT news_news, news_keywords, news_subject, news_image_front_default FROM ".DB_NEWS." WHERE news_id=:newsid LIMIT 1", [':newsid' => $newsid]);
 if (dbrows($result)) {
 $data = dbarray($result);
 $info = [
 'title' => $data['news_subject'].' - '.$settings['sitename'],
 'description' => $data['news_news'],
 'url' => $settings['siteurl'].'infusions/news/news_id='.$newsid,
 'keywords' => !empty($data['news_keywords']) ? $data['news_keywords'] : $settings['keywords']
 ];
 }
 self::setValues($info);
 }
0 replies
A
Apis
A
Apis 12
  • Junior Member, joined since
  • Contributed 42 posts on the community forums.
  • Started 13 threads in the forums
  • Started this discussions
answered
Junior Member

Don't work sad
0 replies

Labels

Statistics

  • Views 0 views
  • Posts 4 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

K
K
karrak 32
Van mi sosem változik..smile
  • Senior Member, joined since
  • Contributed 310 posts on the community forums.
  • Started 94 threads in the forums
  • Answered 1 question
A
A
Apis 12
  • Junior Member, joined since
  • Contributed 42 posts on the community forums.
  • Started 13 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet