Developer forum

Forum » Templates » Facebook "like" buttons versus News V2

Facebook "like" buttons versus News V2

Lise Trabjerg Pedersen
Reply
Anybody else here, who during the last weeks has experienced, that facebook "like" buttons in News V2 List suddenly don't work anymore?
I have a Dw solution where I have used the standard facebook like button, and another, where I have used "addthis" functionality.
Both was linked up to "http://www.solution.dk/<!--@News:Href-->" and has worked nice before.
But now it is only linking to the site, not the news-item-page.

And I simply can't find a way to repair it.

Have some of you had the same problem - I guess it's a facebook-thing, not a Dw-thing - but still, I would like to hear if some of you have had the same problems, and found a solution?

/Lise

Replies

 
Lise Trabjerg Pedersen
Reply
Next step - I have added the meta.description and the meta.title in the facebook og:properties in head, and is usings these for title and teaser in the news module - works fine. But the image!
Has anybody found a way to "force" facebook to choose the image from the news item, and not a "default" picture, defined in the "og:image" property?

I can see that wordpress and drupal and others has standard scripts, that helps this topic. Would be nice, if Dynamicweb had something like that...

/Lise
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
Hi Lise,

You can accomplish something like this with the Extensibility API; through a TemplateExtender to be exact. Here's a quick example:

using System;
using Dynamicweb.Frontend;
using Dynamicweb.Modules.News.Extensibility;
using Dynamicweb.Rendering;

namespace CustomModulesDemo
{
  public class AddOgImageMetaTag : NewsItemDetailsTemplateExtender
  {
    const string ogMetaTag = "<meta property=\"og:image\" content=\"{0}\"/>";

    public override void ExtendTemplate(Template template)
    {
      PageView.Current().Meta.Add(String.Format(ogMetaTag, Item.NewsImage);
    }
  }
}
This does require some custom coding in the project though. Also, you may need to parse the Item.NewsImage property as, if I am not mistaken, it returns a relative path starting with ..

I agree it would be nice if Dynamicweb had better support for this out of the box, as this is getting more and more common. You may want to request it as a feature in the Feature Requests forum.

Hope this helps,

Imar
 
Lise Trabjerg Pedersen
Reply

I did another thing - and I don't think facebook would recommend it. I removed the og:image property from the master - now the picture from the news item is choosen. But if it will keep on working, i'll just have to wait and see...

 

You must be logged in to post in the forum