I did test some different SEF code and untill now it works. The only thing you have to do is that you delete the text after the ":". This is something that gets returned from Joomla.
I will send you a private message through this board with some information. Hopefully you can extend the Phoca Facebook Comments module then with this feature.
***** EDIT *****
Sorry I saw I can't send private message yet. So here some code and explanation:
First you have to adjust your default.php file of the Phoca Facebook Module. Change the following:
Code: Select all
//$option = JRequest::getVar('option', '');
//$view = JRequest::getVar('view', '');
//$xid = md5(JURI::base() . $option . $view) . 'pfc';
$uri = &JFactory::getURI();
$xid = md5('pfc'.$uri->toString());
To the next code:
Code: Select all
$pOption = JRequest::getVar('option');
$pView = JRequest::getVar('view');
$pId = JRequest::getVar('id');
if ( strpos($pId,':') > 0 ) {
$pId = substr($pId,0,strpos($pId,':'));
}
$pItemid = JRequest::getVar('Itemid');
$pCatid = JRequest::getVar('catid');
if ( strpos($pCatid,':') > 0 ) {
$pCatid = substr($pCatid,0,strpos($pCatid,':'));
}
$xid = urlencode('option='.$pOption.'&view='.$pView.'&id='.$pId.'&catid='.$pCatid.'&Itemid='.$pItemid);
As you can see I added a strpos() to the $pId and $pCatID. This is because Joomla is adding the SEF URL behind the ":" for these items. But these can't be stored in the xid as I tested. If you do the URL isn't correct all the time. without the ":" it is correct as I have tested.
The rest of your Phoca Facebook Comments can be left as it is. But you could add an administrator page that allows administrators of Joomla to view all facebook comments made on the website. Here is some example code to do this (not Joomla ready, because I am not really into Joomla administrators code):
Code: Select all
<?php
session_start();
require '../src/facebook.php';
/* Added variables */
define("APP_ID","999999998693633");
define("APP_SECRET","9999999338e65e5f518c11d93cc19baa");
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => APP_SECRET,
'cookie' => true,
));
$appAccessToken = $facebook->getAccessToken();
$appAccessToken = APP_ID.'|'.APP_SECRET;
?>
<html>
<head>
<title>All facebook comments</title>
<style>
body {
font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
}
h1 a {
text-decoration: none;
color: #3b5998;
}
h1 a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo $facebook->getAppId(); ?>',
status : false, // check login status
cookie : false, // enable cookies to allow the server to access the session
xfbml : false // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<h1><a href="comments.php">All Facebook comments</a></h1>
<table>
<tr>
<td>Link</td>
<td>Datum</td>
<td>Naam</td>
<td>Comment</td>
</tr>
<?php
try {
$fql = "SELECT xid, object_id, post_id, fromid, time, text, id, username, reply_xid FROM comment WHERE xid IN (SELECT xid FROM comments_info WHERE app_id=".$facebook->getAppId().")";
$param = array('method' => 'fql.query', 'query' => $fql, 'callback'=> '');
$fqlResult = $facebook->api($param);
for($i = 0; $i < count($fqlResult); $i++) {
echo '<tr>';
echo '<td><a href="http://www.markinthedark.nl/index.php?'.urldecode($fqlResult[$i]["xid"]).'" target="_blank">Goto comment</a></td>';
echo '<td>'.date("d-m-Y H:i:s", $fqlResult[$i]["time"]).'</td>';
try {
$fql2 = "SELECT first_name, last_name, profile_url FROM standard_user_info WHERE uid=".$fqlResult[$i]["fromid"];
$param2 = array('method' => 'fql.query', 'query' => $fql2, 'callback'=> '', 'access_token' => $appAccessToken);
$fqlResult2 = $facebook->api($param2);
if(count($fqlResult2) != 1) {
echo '<td>No user found!</td>';
}
else {
echo '<td><a href="'.$fqlResult2[0]["profile_url"].'" target="_blank">'.$fqlResult2[0]["first_name"].' '.$fqlResult2[0]["last_name"].'</a></td>';
}
} catch (FacebookApiException $e) {
echo '<td>'.$e.'</td>';
}
echo '<td>'.$fqlResult[$i]["text"].'</td>';
echo '</tr>';
}
} catch (FacebookApiException $e) {
echo $e;
}
?>
</table>
</body>
</html>
Ofcourse you need to change this into Joomla code for an administrator. But I think you did this before
. As you can see I add a facebook.php file. This file is from the Facebook PHP SDK which can be downloaded here:
https://github.com/facebook/php-sdk/
Also the URL I decode can be set to SEF again in Joomla. If you build a Joomla dmin page for this I believe you can recalculate the SEF URL again as follows:
http://docs.joomla.org/Routing
But without it it works also. Please let me know if you will build this admin page. Because to my opinion it is very helpfull to have this option.