Unfortunately I'm not familiar with s9y plugins but from docs and examples I'm slowly getting along to create a simple question and answers-plugin. I'm aware of the existence of a plugin featuring a full blown discussion board. I'm looking for something slightly different, though.
I could succesfully create db tables, enter question for entry in appointed field in the backend as well as save that question to the database.
When fetching single entries featuring questions, I'd like to display those along with answers.
Something like:
Code: Select all
case 'frontend_display':
if(in_array($eventData['id'], $this->editEntries)) {
$eventData['body'] .= $eventData['question'];
$eventData['body'] .= $this->getAnswerForm();
$eventData['body'] .= $eventData['answers'];
}
return true;
break;
Code: Select all
case 'frontend_fetchentries':
case 'frontend_fetchentry':
if(in_array($eventData['id'],$this->editEntries)) {
$questionID = $eventData['id'];
$cond = $join = '';
$cond .= "entryquestions.question AS question,\n";
if (empty($eventData['addkey'])) {
$eventData['addkey'] = $cond;
} else {
$eventData['addkey'] .= $cond;
}
$join = "LEFT JOIN {$serendipity['dbPrefix']}entryquestions AS entryquestions ON (e.id = entryquestions.entryid) ";
$cond = "entryid = $questionID";
if (empty($eventData['and'])) {
$eventData['and'] = " WHERE $cond ";
} else {
$eventData['and'] .= " AND $cond ";
}
if (empty($eventData['joins'])) {
$eventData['joins'] = $join;
} else {
$eventData['joins'] .= $join;
}
$this->displayQuestionId = $questionID;
$serendipity['plugin_vars']['displayQuestionId'] = $questionID;
@define('PLUGIN_VARS_DISPLAYQUESTION_ID', $questionID);
}
return true;
break;
The freetag plugin on the opposite works with hook entry_display instead, where an additional db query is run in order to get entries' tag data.
Hope, I'm on the right track and thank in advance for any plugin dev help.
ciao, Peggy