7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Creating A F.A.Q. page, How do I group questions?
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 631 Views |
-
Creating A F.A.Q. page, How do I group questions?

7 May 2010 at 4:18am
Hi all
I want to have administrators be able to enter faq questions and assign them to groups to achieve an output like this:
QuestionGroup1
Question 1
Answer 1
Question 2
Answer 2
QuestionGroup 2
Question 3
Answer 3I am having a heck of a time getting this to work in the admin.
I created a "FAQPage" and added 2 tabs "Question Groups" and "Questions"
Questions doesn't allow me to assign the question to a question group.
Can someone give me some insight to this?
-John
Here is my codeclass FAQPage extends Page
{
static $has_many = array (
'QuestionGroups' => 'QuestionGroup'
);public function getCMSFields()
{
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.QuestionGroup", new DataObjectManager(
$this,
'QuestionBunchs',
'QuestionBunch',
array('QuestionGroup'=>'QuestionGroup'),
'getCMSFields_forPopup'
));
$f->addFieldToTab("Root.Content.Questions", new DataObjectManager(
$this,
'FaqQuestions',
'FaqQuestion',
array('Question'=>'Question','Answer'=>'Answer'),
'getCMSFields_forPopup'
));
$f->renameField("Root.Content.Questions", "Question Groups");
return $f;
}}
class FaqQuestion extends DataObject {
static $db = array(
'Question' => 'Text',
'Answer' => 'HTMLText'
);
static $has_one = array (
'QuestionBunch' => 'QuestionBunch'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Question'),
new TextareaField('Answer')
);
}}
class QuestionBunch extends DataObject {
static $db = array(
'QuestionGroup' => 'Text',
'Order' => 'Int'
);
static $has_many = array (
'FaqQuestions' => 'FaqQuestion'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('QuestionGroup')
);
}}
-
Re: Creating A F.A.Q. page, How do I group questions?

7 May 2010 at 4:32am
You need a nested DOM..
Page -> has_many -> FAQGroups -> has_many ->FAQs.
<% control FAQGroups %>
$Title
<% control FAQs %>
$Question $Answer
<% end_control %>
<% end_control%> -
Re: Creating A F.A.Q. page, How do I group questions?

7 May 2010 at 4:36am
I guess my question is, How do I get in the ADMIN, the ability to attach questions to FAQGroups?
In the questions tab, it just has the ability to enter question and answer. What am I missing to pick what group its a part of?
John -
Re: Creating A F.A.Q. page, How do I group questions?

7 May 2010 at 4:40am
In the edit form for your question group, put a DOM in there for adding FAQs..
Holder page..
new DataObjectManager($this,'QuestionGroups','QuestionGroup');
QuestionGroup
return new FieldSet(
new TextField('Title'),
new DataObjectManager($this,'FAQs','FAQ')
);
| 631 Views | ||
|
Page:
1
|
Go to Top |

