CMSMS and sharing to FB

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
wmdvanzyl
Forum Members
Forum Members
Posts: 214
Joined: Fri May 06, 2011 12:48 pm

CMSMS and sharing to FB

Post by wmdvanzyl »

Hi All..

Right off the bat i will state that i am very green with sharing content to social media.

When i share a post (news article or blog post) to Facebook, the thumbnail doesn't show. I have read that you need to include a tag in the head that looks like this

Code: Select all

<meta property="og:image" content="http://example.com/image.jpg"/>
Now that seems fine, but seeinf as the image in question will be in the news feed or blog, that information is not available to be placed in the head section of the template (obviously).

So how do you get around it? Any advice will be appreciated.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: CMSMS and sharing to FB

Post by Jo Morg »

CMSMS page templates are parsed in an uncommon order, but one that allows you to solve that a other similar needs:
  1. everything from the start of the template up to the < head > tag;
  2. everything from the < body > tag to the end of the template;
  3. everything between < head > and </ head >;
That allows the use of Smarty variables on the head section that have been set on other sections of the template, including the body and content blocks.

Another way would be to assign the output of the smarty tags to variables on the top of the template, usually right after the {process_pagedata} something like {content assign=mycontent} and then you can use {$mycontent} and the variables already assigned by tag calls made inside of the content or other blocks. There are a few changes to take into account since CMSMS 2+ but they are well documented, so if you do a search on the forum you'll get more info about it.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: CMSMS and sharing to FB

Post by velden »

Useful links:

Test your page for Facebook:
https://developers.facebook.com/tools/debug/
Sometimes useful too to refresh an image cached by Facebook.

TIP: use an temporary url for testing.

It's useful to understand how Facebook (or others) determine what to display. What url they will use, image sizes etc.
It occurs to me that while testing 'sharing' it sometimes takes two or three tries before facebook actually displays the image for a 'new' page (that is a page shared for the first time)

Info:
https://developers.facebook.com/docs/sh ... ers#markup
wmdvanzyl
Forum Members
Forum Members
Posts: 214
Joined: Fri May 06, 2011 12:48 pm

Re: CMSMS and sharing to FB

Post by wmdvanzyl »

I really appreciate the advice. I will begin looking into this asap. :)

Why should i use a temporary URL for testing?
Post Reply

Return to “Modules/Add-Ons”