Pbas
July 12, 2019, 1:53pm
1
Hello,
I use a form to create page and I need to create page in a sub level location … and it doesn’t work.
I use this FAQ https://www.xwiki.org/xwiki/bin/view/FAQ/How+can+I+create+a+new+page+based+on+a+form
but if I use
<input type="hidden" name="spaceName" value="FAQ.NewLevel"/>
my new page is create in a space named ‘FAQ.NewLevel’ and not in “NewLevel” sub space of “FAQ” location.
How can I do?
(I use XWiki 10.11.3 version)
Thxs.
Pascal B
Pbas
July 12, 2019, 2:32pm
2
Ok to fix this issue, I must use this way (I add space ub level in a list:
#set ($Location= ["$!{request.spaceName}",‘NewLevel’])
{{velocity}}
#if("$!request.docName" != '')
## Request for creating a new instance
## Add sub level where to create the new page
#set ($Location= ["$!{request.spaceName}",'NewLevel'])
#set($targetDocReference = $services.model.createDocumentReference('', $!{Location}, "$!{request.docName}"))
$targetDocReference
$response.sendRedirect($xwiki.getURL($targetDocReference, 'inline', "template=${escapetool.url($request.template)}&parent=${escapetool.url($request.parent)}"))
## Stop processing, since we already sent a redirect.
#stop
#end
= Add a new question =
{{html}}
<form action="" id="newdoc" method="post">
<div>
<input type="hidden" name="parent" value="${doc.fullName}"/>
<input type="hidden" name="template" value="FAQ.FAQTemplate"/>
<input type="hidden" name="sheet" value="1"/>
<input type="hidden" name="spaceName" value="FAQ"/>
Document: <input type="text" name="docName" value="Enter your question here" class="withTip" size="50"/>
<span class="buttonwrapper"><input type="submit" value="Create this FAQ" class="button"/></span>
</div>
</form>
{{/html}}
{{/velocity}}
Probably there is a better way and I I hesitate to correct the FAQ.
Pbas
July 17, 2019, 9:23am
3