I’d like to be able to post status updates to a page, similar to the forum application when you add a reply to a topic with the time stamp. Any ideas how to do this?
Could you give some more detailed example since I don’t fully understand what you mean (I’m also not an expert of the forum app)?
Questions for you:
- What kind of status update you have in mind?
- What part of the page should be modified with these status updates?
- How will those status updates be triggered?
Thanks
Yeah, sorry.
So basically i’m creating an issue tracker AWM and want to add the ability to post status updates that appends the update to the end of the page with the time stamp set with a header 2 tag.
As for how it would be triggered:
The way I imagined it, is there would be text window below the content of the page with a submit button to append the new status update.
BTW in case you haven’t seen it, there’s an extension that does something similar at http://extensions.xwiki.org/xwiki/bin/view/Extension/Task%20Manager%20Application
That said, it’s great that you’re building your own tracker with AWM!
ok so that’s easy:
- For the form you just need to use HTML using the HTML macro and set the action to be empty so that your page is called again.
- Then in your page/sheet, use the velocity macro to perform the content update action. See https://www.xwiki.org/xwiki/bin/view/FAQ/How%20can%20I%20create%20a%20new%20page%20based%20on%20a%20form for a similar example.
- To change the page content, simply use
$doc.setContent()
and$doc.getContent()
to get the current content and to append some new content.
Sweet, thanks for the info.
Sorry to bring up an old thread. So i’m using the form to create a new page, but I would like for the action to retain the space its in when its creating the new document.
<input type="hidden" name="spaceName" value="FAQ"/>
Instead of using FAQ, I want velocity to read the current space it is in and set the space name to that value.
you can use: $doc.space
as in:
<input type="hidden" name="spaceName" value="$doc.space"/>
For more information on scripting and bindings, see http://platform.xwiki.org/xwiki/bin/view/DevGuide/Scripting#HBindings
Thanks. Seems to not work well when it’s dealing with nested space names. Here’s an example of my setup. This is creating nested spacenames under the Home page.
Main
Main.SpaceName
Main.SpaceName.Doc1
Main.SpaceName.Doc2
I’m using the velocity script to call the space name at Main.SpaceName to create the new document, the problem is when it creates the new page it sets the spacename to “Main.SpaceName” instead of “SpaceName” which is nested under “Main”. I tried using $doc.space and $doc.fullName and neither give me what I need.
Screenshots to give you examples:
And what’s wrong with that? The name of the current space is “Main.SpaceName” not “SpaceName”. The space name contains the full path from the top level space (e.g. Main) to the current nested space (e.g. SpaceName). But maybe you’re using the submitted space name in the wrong way. In any case, if you really want the last part of the space name then you can use:
$doc.documentReference.lastSpaceReference.name
Hope this helps,
Marius
Is there any documents that reference “$doc.documentReference.lastSpaceReference.name” ? I searched the scripting documentation and couldn’t find anything.
Awesome. I couldn’t find this in the document for some reason yesterday but thanks for the help.