I am a bit confused and unsure if I have made an error in setting up a model admin for an faq. I think model admin is great and the faq seemed ideal for administering it but when I come to display if I wonder if I have the wrong end of the stick and shouldn't have used modeladmin
In more detail I have an faqadmin which enables the administrator to create frequent questions and answers and then to categorise them.
<? class FaqAdmin extends ModelAdmin {
protected static $managed_models = array(
'Faq',
'FaqCategory'
);
static $url_segment = 'faq'; // will be linked as /admin/faq
static $menu_title = 'FAQ Admin';
}
?>
This is all working well my problem comes when I want to display the faq grouped by category. I can pull back the data
function getFaqCategory() {
return DataObject::get("FaqCategory", "", "", "", "");
}
function getFaq() {
$category = DataObject::get_one("FaqCategory");
return ($category) ? DataObject::get("Faq", "$category.ID", "DisplayOrder ASC", "", "") : 'false';
but how do I nest the getFaq inside the getFaqCategory? What I have so far is:
<% control getFaqCategory %>
$Title
<% control getFaq %>
<p class="orange">Q: $Question</p>
<p>$Answer</p>
<% end_control %>
<% end_control %>
Do I need to nest the function instead? If so, how?
Many thanks
MM