Dashboard > Castle Contrib > ... > Castle.MonoRail.ViewComponents > Faq Item Component
Log In   View a printable version of the current page.
Faq Item Component
Added by James Curran, last edited by James Curran on Aug 27, 2007  (view change)
Labels: 


ViewComponent to build one item of a Frequently Asked Questions list. The generated markup displays the question, and using DHTML, displays & hides the answer when the question text is clicked.

public class FaqItemComponent

Remarks

FaqItemComponent is one of two different components for creating FAQ pages.

It is intended for it to format FAQ entries where the text in hard-coded in the view. To format FAQ entries where the text is comes from an external data source, see [Faq List Component].

FaqItem is a block component which has two required sections, "question" and "answer", and four optional parameters.

Section Description
#question Contains the text of a Frequently asked question. The text is always displayed on the page. Clicking this text will display the answer.
#answer Contains the text of the answer to the FAQ. The text is initially hidden, and only displayed when the question is clicked.
Parameter Description
QuestionCssClass CSS Class used for the DIV block holding the question. (Default: Question)
AnswerCssClass CSS Class used for the DIV block holding the answer. (Default: Answer)
WrapItems If set to "true", each question/answer block will be wrapped in a LI tags, so that a series of FaqItemComponents can be made a ordered (OL) or unordered (UL) list. (Default:False)
Sticky If set to "True", the values given for the other parameters will be used for all subsequent FaqItemComponents on this page. If explicitly set to "False", previously save values are forgotten.(Default:False)

NOTE: This ViewComponent makes use of the prototype.js javascript library, and therefore requires the following line appears in either the view which FaqItemComponent is used, or the layout template used by that view: $AjaxHelper.GetJavascriptFunctions()

Copyright © 2007, James M. Curran
Licensed under the Apache License, Version 2.0

Example

#blockcomponent (FaqItemComponent)
#question
Is MonoRail stable? Why it's not 1.0?
#end
#answer
Yes, very stable, albeit there's always room for improvements.
Check our issue tracker.
We are not 1.0 because there are important features not
implemented yet, like Caching and Logging support.
#end
#end

will generate the following markup:

<div id="Faq_Q1" onclick="Element.toggle('Faq_A1')" class="Question">
Is MonoRail stable? Why it's not 1.0?
</div>
<div id="Faq_A1" style="display:none" class="Answer">
<br/>
Yes, very stable, albeit there's always room for improvements.
Check our issue tracker.
We are not 1.0 because there are important features not
implemented yet, like Caching and Logging support.
<hr/>
</div>

Site running on a free Atlassian Confluence Community License granted to Castle Project. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators