Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-09-19 19:03:00

CodeWalker
Member
From: Hampshire, UK
Registered: 2010-01-08
Posts: 110
Website

[howto] Facebook Meta Tags

I put up a quick guide to adding Facebook Metas and keep them valid. There is a guide to this one TXPTips but seems a bit out of date and I couldn’t get parts of it to work. Heres what I came up with:

Facebook Meta

Last edited by CodeWalker (2013-09-19 19:03:54)

Offline

#2 2013-09-19 21:38:48

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [howto] Facebook Meta Tags

You could simplify that down to:

<txp:variable name="facebook"><txp:php>
    echo intval(stripos($_SERVER['HTTP_USER_AGENT'], 'facebook') !== false);
</txp:php></txp:variable>

<txp:if_variable name="facebook" value="1">
    <!-- Meta tags. -->
</txp:if_variable>

Which also avoids calling fragile template handler functions. Those functions might not be there in the future releases (e.g. yield() is going to be gone in 4.6.0). There also are bunch of header and general conditional plugins that can perform similar checks.

Last edited by Gocom (2013-09-19 21:38:58)

Offline

#3 2013-09-22 10:52:46

CodeWalker
Member
From: Hampshire, UK
Registered: 2010-01-08
Posts: 110
Website

Re: [howto] Facebook Meta Tags

Thanks Gocom. Im sure I tried something along those lines and it didn’t work. Im not great at PHP though! Ill test this out. I’ll update my blog post.

Offline

Board footer

Powered by FluxBB