Open Graph Tags example for use with Facebook

page.headerData.120 = COA
page.headerData.120 {
10 = TEXT
10 {
typolink.parameter.data = TSFE:id
typolink.forceAbsoluteUrl = 1
typolink.returnLast = url
typolink.additionalParams.cObject = COA
typolink.additionalParams.cObject {
10 = TEXT
10.dataWrap = &tx_ttnews[tt_news]={GP:tx_ttnews|tt_news}
10.if.isTrue.data = GP:tx_ttnews|tt_news
20 = TEXT
20.dataWrap = &tx_ttnews[cat]={GP:tx_ttnews|cat}
20.if.isTrue.data = GP:tx_ttnews|cat
}
wrap = <meta property=”og:url” content=”|”/>
}
20 < page.headerData.1
20 {
wrap = <meta property=”og:title” content=”| {$siteTitle}”/>
}

30 = TEXT
30.value =
30.wrap = <meta property=”og:site_name” content=”|{$siteTitle}”/>

40 = TEXT
40.value = <meta property=”og:description” content=”” />
40.wrap = <meta property=”og:type” content=”website” />|

}

In additions to the above, we can also set the og:image property on a news detail page like given below:
This new updated Code also includes a default image when news has no image.

page.headerData.120.50 = COA
page.headerData.120.50 {
20 = CONTENT
20 {
table = tt_news
select {
pidInList = 18
andWhere = uid={GP:tx_ttnews|tt_news}
andWhere.insertData =1
selectFields = uid,pid,image
}
renderObj = COA
renderObj {
10 = TEXT
10.value =<meta property=”og:image” content=”http://www.mydomain.com/uploads/pics/
20 = TEXT
20 {
field = image
split {
token = ,
max = 1
cObjNum = 1
1.current = 1
}
ifEmpty.cObject = TEXT
ifEmpty.cObject {
value = alt-image.jpg
}

}
30 = TEXT
30.value = ” />
}
}
}

Html tags like table,p are not comming for the newly added RTE field in tt_news

While I was working on some project, there was a requirement to add extra RTE field for tt_news. I extended the table tt_news by adding RTE fields. I faced the following problem

1) I inserted the table but after saving the tt_news record the table started disappearing

2) <p> tag was not inserted automatically for press of Enter

After doing some research I found the solution

1) Set the transformation mode for the RTE to “ts_css” in ext_tables.php

ex-

if (t3lib_extMgm::isLoaded(‘css_styled_content’)) {
t3lib_extMgm::addPageTSConfig(‘
# RTE mode for table “tt_news”
RTE.config.tt_news.exampleField.proc.overruleMode=ts_css’);
}

Here the table used is tt_news and the filed name is exampleField

2) For P tag to be inserted for every new line character I added the code

$rowfrntbl[$tblcol]=$pObj->local_cObj->stdWrap($rowfrntbl[$tblcol], $pObj->conf[‘general_stdWrap.’])

Here I am using hook  for tt_news to get the desired result.