Last modified by Simon Urli on 2023/10/10

<
From version < 50.1 >
edited by Thibaut Camberlin
on 2010/09/07
To version < 52.1 >
edited by Ricardo Rodríguez
on 2010/12/11
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.ThibautCamberlin
1 +XWiki.rrodriguez
Content
... ... @@ -1,4 +1,6 @@
1 -{{box cssClass="floatinginfobox" title="**Contents**"}}{{toc/}}{{/box}}
1 +{{box cssClass="floatinginfobox" title="**Contents**"}}
2 +{{toc/}}
3 +{{/box}}
2 2  
3 3  This tutorial will show you how to build a Frequently Asked Questions (FAQs) Application much like the one you can find on the [[FAQ page>>xwiki:FAQ.WebHome]]. This is a very simple application that makes use of XWiki's classes, properties, and objects. It also uses a technique that you may frequently use as the basis for several different kinds of applications.
4 4  
... ... @@ -26,18 +26,16 @@
26 26  
27 27  = Go to the Class Editor Wizard =
28 28  
29 -Five pages, which collectively make up a Class Editor Wizard application, have been developed to assist you in this process. Enter a search query for the keyword "XWikiClasses". This should return a document called XWikiClasses in the XWiki space (i.e. XWiki.XWikiClasses). This is the homepage of the class wizard creator: you are now ready to start building your FAQs application.
31 +Five pages, which collectively make up a Class Editor Wizard application, have been developed to assist you in this process. Be sure you have imported the default set of XWiki pages available in the XAR matching your [[XWiki Enterprise installation>>xwiki:Main.Download]]. Enter a search query for the keyword "XWikiClasses". This should return a document called XWikiClasses in the XWiki space (i.e. XWiki.XWikiClasses). This is the homepage of the class wizard creator: you are now ready to start building your FAQs application.
30 30  
31 31  = Create the FAQ Class =
32 32  
33 33  * On the Class Editor wizard entry page (XWiki.XWikiClasses), under the heading "Create a new data type", enter the following web space and class name:
34 34  ** Space: FAQ
35 -** Class: FAQ
36 -(((
37 +** Class: FAQ(((
37 37  image:CreateANewClass.PNG
38 38  )))
39 -* Click the "Create this Class" button. You should then see a code page with the following code:
40 -(((
40 +* Click the "Create this Class" button. You should then see a code page with the following code:(((
41 41  {{code language="none"}}
42 42  {{velocity}}
43 43  ## Replace Main with the Space where you want your documents to be created.
... ... @@ -53,11 +53,15 @@
53 53  
54 54  In the code, change the word "Main" with the name of the space where you want you FAQ pages to be created as the commented instructions in the page code suggest. Replace the word "Main" with the word "FAQ". The line of code should now look like this:
55 55  
56 -{{code language="none"}}#set($defaultSpace = 'FAQ'){{/code}}
56 +{{code language="none"}}
57 +#set($defaultSpace = 'FAQ')
58 +{{/code}}
57 57  
58 58  You can also change the default parent of the new FAQ documents that are going to be created. To do so, replace the variables with the name of your document. The line of code should now look like this:
59 59  
60 -{{code language="none"}}#set($defaultParent = 'FAQ.WebHome'){{/code}}
62 +{{code language="none"}}
63 +#set($defaultParent = 'FAQ.WebHome')
64 +{{/code}}
61 61  
62 62  Click the "Save & View" button. The class is now created and you should be looking at a page titled "Class: FAQ" that looks like this:
63 63  
... ... @@ -73,12 +73,10 @@
73 73  In our document, we'll store both a //question// and an //answer//. So we need a property for each.
74 74  
75 75  * Enter the text //question// in the "NAME" field of the Class Editor panel: the "ADD PROPERTY" panel is in the right column.
76 -* Choose a TextArea type for the property and then click the "ADD PROPERTY" button. The TextArea will ultimately give us a multi-line text field in our authoring template.
77 -(((
80 +* Choose a TextArea type for the property and then click the "ADD PROPERTY" button. The TextArea will ultimately give us a multi-line text field in our authoring template.(((
78 78  image:AddQuestionProperty.PNG
79 79  )))
80 -* Configure this property with the following values (actually, if you are using the current XWiki version, you don't need to change anything but the Pretty name ? all the rest are the default values):
81 -(((
83 +* Configure this property with the following values (actually, if you are using the current XWiki version, you don't need to change anything but the Pretty name ? all the rest are the default values):(((
82 82  image:QuestionProperty.PNG
83 83  )))
84 84  * Now add a property called //answer// in the same way that you did for the "question" property (choosing TextArea for the property type)
... ... @@ -87,8 +87,7 @@
87 87  
88 88  = Create the Page Design Sheet =
89 89  
90 -* After the previous step you are now on the FAQClass page which should look like this:
91 -(((
92 +* After the previous step you are now on the FAQClass page which should look like this:(((
92 92  image:FAQClass2.PNG
93 93  )))
94 94  * Click the first button ("CREATE THE DOCUMENT SHEET") to create the document sheet (the Page Design Sheet). This sheet determines how your page's objects will be rendered to the user. The document is automatically created.
... ... @@ -97,8 +97,7 @@
97 97  * Using the menu on the right, add a XWiki.SheetClass object to the page
98 98  ** **Adding the XWiki.SheetClass object is important. It's because of this object that users will be sent to form edition mode when editing FAQ entries**
99 99  * Click "Save & View"
100 -* If you edit the page in wiki mode, you will see the following code:
101 -(((
101 +* If you edit the page in wiki mode, you will see the following code:(((
102 102  {{code language="none"}}
103 103  {{velocity}}
104 104  ## You can modify this page to customize the presentation of your object.
... ... @@ -113,8 +113,7 @@
113 113  #end
114 114  {{/velocity}}
115 115  {{/code}}
116 -)))
117 -Let's take a moment now and analyze this code:
116 +)))Let's take a moment now and analyze this code:
118 118  
119 119  * The first line retrieves the FAQ.FAQClass from the wiki
120 120  * Then we iterate through all its properties and display their values for the current document in a definition list.
... ... @@ -132,14 +132,14 @@
132 132  
133 133  = Create the Authoring Template =
134 134  
135 -* Click on "FAQClass" in the breadcrumb. The document should look like this:
136 -(((
134 +* Click on "FAQClass" in the breadcrumb. The document should look like this:(((
137 137  image:FAQClass3.PNG
138 138  )))
139 139  * Notice that now, there is a link for the FAQSheet in place of the button that was previously there
140 -* Click on the "CREATE THE DOCUMENT TEMPLATE" button. The Authoring Template will be automatically created. If you click on "View the template document" and edit that page in wiki mode, you will see the following code:
141 -(((
142 -{{code language="none"}}{{include document="FAQ.FAQSheet"/}}{{/code}}
138 +* Click on the "CREATE THE DOCUMENT TEMPLATE" button. The Authoring Template will be automatically created. If you click on "View the template document" and edit that page in wiki mode, you will see the following code:(((
139 +{{code language="none"}}
140 +{{include document="FAQ.FAQSheet"/}}
141 +{{/code}}
143 143  )))
144 144  * Note that we changed the space name preceding the page name also because we want all of our FAQ pages to reside in the same XWiki space
145 145  * Remember that all our documents will be copies of the Authoring Template used as a prototype so the content will be copied in all our FAQs documents and will execute the Design Sheet code in the context of the current document. See the [[dedicated page>>DevGuide.IncludeInVelocity]] for more information regarding this technique.
... ... @@ -149,10 +149,10 @@
149 149  * If you're on the template page, click on "FAQClass" in the breadcrumb to get back to the FAQ Class page
150 150  * At the bottom of the page, look for the following error message: "The template does not contain an object of type FAQClass. Add a FAQ object to the template »."
151 151  * Click on "Add a FAQ object to the template »"
152 -* Congratulations: you just created an Authoring Template! You're almost done now.
153 -(((
151 +* Congratulations: you just created an Authoring Template! You're almost done now.(((
154 154  image:FAQClass4.PNG
155 155  )))
154 +
156 156  = Create a home page for the FAQ application =
157 157  
158 158  You want your users to be able to see a list of all existing questions and answers and to add new questions. The best way to do this is to put the FAQ application in its own space and to use that space's homepage to display existing questions.
... ... @@ -185,7 +185,7 @@
185 185  #else
186 186   #foreach ($item in $results)
187 187   #set($faq = $xwiki.getDocument($item))
188 - * [[${faq.display("question").replace("<p>", "").replace("</p>", "")}>>${item}]]
187 + * [[${faq.display("question").replace("<p>", "").replace("</p>", "")}>>${item}]]
189 189   #end
190 190  #end
191 191  {{/velocity}}
... ... @@ -254,12 +254,10 @@
254 254  Now let's just create a new document in our application to test it out.
255 255  
256 256  * Under the "Add a new question" header, enter a document title in the //Document// field and click //Create this FAQ//. For example, enter //What is the meaning of life?//.
257 -* You can then enter your question in longer form using the //Question// field on the template, like this:
258 -(((
256 +* You can then enter your question in longer form using the //Question// field on the template, like this:(((
259 259  image:FAQSheetEdit.PNG
260 260  )))
261 -* Click //Save & View// and then you will see the newly created document, like this:
262 -(((
259 +* Click //Save & View// and then you will see the newly created document, like this:(((
263 263  image:FAQSheetView.PNG
264 264  )))
265 265  * Go back to the "FAQ.WebHome" page to see the list of existing questions

Get Connected