How your Drupal 7 Application appear in facebook ?

Sat, 02/18/2012 - 16:41 -- meladawy

What if you shared your Drupal web site URL in Facebook !! What is the Title, Description and Image You will Got ? Is that Exactly what You want ?
In this Tutorial i will show You How To control The Appearance of your Drupal Front page In Facebook .

1- Open your Theme Directory "sites/all/themes/XXX" or "themes/XXX" where XXX is your theme name .

2- Open the "template.php" file if its Exists or Create it if its not Exists .

Lets Change our Front Page Meta data with another Meta data that fit our needs by Implementing "hook_process_HOOK" function in our "template.php" file.

3- Copy and Past the Following Code into your "template.php" file . (Make sure that hook_process_HOOK functions is not implemented before)

<?php
/**
 * Implements hook_process_HOOK().
 */
function XXX_process_html(&$vars){
if(drupal_is_front_page()){
$vars['head'] = '
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="http://www.drupalst.com/misc/favicon.ico" type="image/vnd.microsoft.icon" />
<meta content="TTT" about="/" property="og:title" />
<meta content="DDD" about="/" property="og:description" />
<meta content="LLL"   property="og:image"  />
<meta content="UUU" property="og:url"  />
<link rel="shortlink" href="/" />
<meta name="generator" content="Bluefish 2.0.3" />
<link rel="canonical" href="/" />
<title>TTT</title>
';
}
}

Replace "TTT" with your site title, "DDD" with the description of ur web site, "LLL" with the thumbnail image link and "UUU" with the url of your web site

4- Save the changes , Now you can test This changes by visiting http://developers.facebook.com/tools/debug/ and debug your web site link

5- Finally Share your web site with your Friends :) .

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.