Hi,
I’m looking for the following and doesn’t no how to have that either added with an extention or by programmatically added objects to the Template.
- I want to add a field telling my the security classification of a page. For example “Top Secret” and I want to I can group pages based on that. At the moment I’m solving that with TAGs, but that is not really what I want. I want that embedded into the page as on Object I can use for additional decissions and for grouping pages by Security classification.
- I want to add a Information on the “Information” tab below a page to have the origin of that page. e.g. if a page is a copy of a wikipedia page, I want to add that information there.
Any Idea or Template on how to add objects like that to Pages, please?
Kind regards,
kug1977
Hi,I managed to get my Class definied and added the class’ output to the Information Tab. Thanks a lot for the reference @vmassol. I also used the same logic to make my class available as an extention to org.xwiki.platform.panels.documentInformation, where I can select the right value on document edit. And here I struggle a bit with the logic. My Executed Content looks like that
{{velocity}}
#set ($className = 'XWiki.Metadata.DocumentClassificationClass')
#set ($fieldName = 'Level') ## Hier 'Level' nutzen, da dies in deiner Klasse so heißt
#set ($obj = $tdoc.getObject($className))
#if (!$obj)
#set ($obj = $tdoc.newObject($className))
#set ($discard = $tdoc.save("Created Document Classification Class Object.", true))
#end
#set ($classDoc = $xwiki.getDocument($className))
#set ($xclass = $classDoc.getxWikiClass())
#set ($values = $xclass.get($fieldName).getListValues())
#set ($currentValue = "")
#if ($obj)
#set ($currentValue = "$!obj.getValue($fieldName)")
#end
{{html clean="false"}}
<div class="attribute">
<dt><label for="${className}_0_${fieldName}"><strong>Document Classification</strong></label></dt>
<dd>
## Das 'name' Attribut ist der Schlüssel!
## Format: Klassenname_Index_Feldname (0 steht für das erste Objekt)
<select name="${className}_0_${fieldName}" id="${className}_0_${fieldName}" class="form-control">
#foreach ($v in $values)
<option value="$escapetool.xml($v)" #if ($v == $currentValue) selected="selected" #end>
$escapetool.xml($v)
</option>
#end
</select>
</dd>
</div>
{{/html}}
{{/velocity}}
and the issue is the line
#set ($discard = $tdoc.save("Created Document Classification Class Object.", true))
I kind of need it to generate and add a object of my class to an old document without it on first “edit”. Works so far, but results in a “Merge” request on the very first “Save” of that altered document.
I understand where the Merge Conflict came from, but I have no solution to get both:
- add the object to a page already in the wiki
- get it added with the selected value on “Save” action
without that line.
Any hint, how to solve that, please?
Kind regards,
Kay-Uwe