Keyword

K2 FB APP ID & ADMINS ID

  • Khan Baba
  • Khan Baba's Avatar Topic Author
  • Offline
  • New Member
More
9 years 2 months ago #146131 by Khan Baba
K2 FB APP ID & ADMINS ID was created by Khan Baba
Dear All,

Please tell me i want to add the following to metas in facebook set.
<meta property="fb:admins" content="1234" />
<meta property="fb:app_id" content="your_app_id" />

// Set Facebook meta data
$document = JFactory::getDocument();
$uri = JURI::getInstance();
$document->setMetaData('og:url', $uri->toString());
$document->setMetaData('og:title', (K2_JVERSION == '15') ? htmlspecialchars($document->getTitle(), ENT_QUOTES, 'UTF-8') : $document->getTitle());
$document->setMetaData('og:type', 'article');
$facebookImage = 'image'.$params->get('facebookImage', 'Small');
if ($item->$facebookImage)
{
$parts = parse_url($item->$facebookImage);
if (JFile::exists(JPATH_SITE.$parts))
{
$image = substr(JURI::root(), 0, -1).str_replace(JURI::root(true), '', $item->$facebookImage);
$document->setMetaData('og:image', $image);
$document->setMetaData('image', $image);
}

Please Log in or Create an account to join the conversation.

More
9 years 2 months ago #146162 by Lefteris
Replied by Lefteris on topic K2 FB APP ID & ADMINS ID
Hi,

This has nothing to do with K2. You need to either add those tags directly in your template's source code or look for a plugin that will do that.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Niels Klint
  • Niels Klint's Avatar
  • Offline
  • New Member
  • Learning by doing
More
8 years 2 months ago - 8 years 2 months ago #156143 by Niels Klint
Replied by Niels Klint on topic K2 FB APP ID & ADMINS ID
I know the question was asked about a year ago, but maybe somebody would like to see an answer how to add the App ID and some other Open Graph meta tags
You can make an override in of the templates - ex. category.php or item.php
Right after
// no direct access
defined('_JEXEC') or die;

in the top of the file you can add the following code
// Added to get and add meta date - ex. $content = $doc->getMetaData( “tag-name” ); 
$doc =& JFactory::getDocument();
$config = JFactory::getConfig();
// Add metatags
$doc->addCustomTag( '
<meta property="og:locale" content="da_DK" />
<meta property="og:locale:alternate" content="en_GB" />
<meta property="og:locale:alternate" content="de_DE" />
<meta property="og:site_name" content="'.$config->get( 'sitename' ).'"/>
<meta property="fb:admins" content="admin number"/>
<meta property="fb:app_id" content="app id number"/>
');
Last edit: 8 years 2 months ago by Niels Klint. Reason: corrected code

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #156147 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 FB APP ID & ADMINS ID
The code seems correct.

You could omit this part since it is most likely already present in your template.
defined('_JEXEC') or die;

This code should be placed in the template's index.php file or a file that is present in all views.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Niels Klint
  • Niels Klint's Avatar
  • Offline
  • New Member
  • Learning by doing
More
8 years 2 months ago #156154 by Niels Klint
Replied by Niels Klint on topic K2 FB APP ID & ADMINS ID
I've corrected to avoid misunderstanding

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #156159 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 FB APP ID & ADMINS ID
Got, it.

My answer is the same however, you can place it in K2 overrides but it would still not appear on every page.

You need to place this code in a core template file, like the index.php file.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Niels Klint
  • Niels Klint's Avatar
  • Offline
  • New Member
  • Learning by doing
More
8 years 2 months ago #156163 by Niels Klint
Replied by Niels Klint on topic K2 FB APP ID & ADMINS ID
I understand what you mean, and if the site is using K2 overall you are absolutely correct.

But I don't think I'm the only one, which have some subsites without K2, where we add Open Graph in another way.
In such cases it can be done with overrides in K2

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #156174 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 FB APP ID & ADMINS ID
For the sake of consistency, for additional og:tags I always use a helper file which is loaded on top of the index.php file.

This way all the functionality is bundled (or bootstrapped) in one file and regardless of the extensions I am using the tags will always be present in one location.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum