[xwiki-devs] Get current space [velocity]
This should be easy, but I am stuck :-( I have created a new panel. The panel shows all the document in the current space. But if the user is in the Main Space, I don't want to show any documents, I want to show all the spaces (except for a couple default spaces). #if $currentSpace = "Main" #set ($hiddenSpaces = ["AnnotationCode", "ColorThemes", "Invitation", "Panels", "Scheduler", "Stats", "XWiki"]) #set($spacesSorted=$xwiki.sort($xwiki.spaces) ) #foreach($space in $spacesSorted) #if (!$hiddenSpaces.contains($space)) * [[$space>>${space}.WebHome]] #end #end #else // Code which shows all documents #end How do I know when I am in the Main Space? -- View this message in context: http://xwiki.475771.n2.nabble.com/Get-current-space-velocity-tp7183403p71834... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Hi, You can get the current space using $doc.space. You can also use $blacklistedSpaces instead of a custom $hiddenSpaces list. There a few syntax errors in your code, but they should be easy to fix. Florin Ciubotaru On Fri, Jan 13, 2012 at 9:46 AM, Hamster <[email protected]> wrote:
This should be easy, but I am stuck :-(
I have created a new panel. The panel shows all the document in the current space.
But if the user is in the Main Space, I don't want to show any documents, I want to show all the spaces (except for a couple default spaces).
#if $currentSpace = "Main" #set ($hiddenSpaces = ["AnnotationCode", "ColorThemes", "Invitation", "Panels", "Scheduler", "Stats", "XWiki"]) #set($spacesSorted=$xwiki.sort($xwiki.spaces) ) #foreach($space in $spacesSorted) #if (!$hiddenSpaces.contains($space)) * [[$space>>${space}.WebHome]] #end #end #else // Code which shows all documents #end
How do I know when I am in the Main Space?
-- View this message in context: http://xwiki.475771.n2.nabble.com/Get-current-space-velocity-tp7183403p71834... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On Fri, Jan 13, 2012 at 10:46 AM, Hamster <[email protected]> wrote:
This should be easy, but I am stuck :-(
I have created a new panel. The panel shows all the document in the current space.
Are you aware of Panels.SpaceDocs ? It does exactly this. Check out the code by editing in "Inline form" edit mode.
But if the user is in the Main Space, I don't want to show any documents, I want to show all the spaces (except for a couple default spaces).
#if $currentSpace = "Main" #set ($hiddenSpaces = ["AnnotationCode", "ColorThemes", "Invitation", "Panels", "Scheduler", "Stats", "XWiki"]) #set($spacesSorted=$xwiki.sort($xwiki.spaces) ) #foreach($space in $spacesSorted) #if (!$hiddenSpaces.contains($space)) * [[$space>>${space}.WebHome]] #end #end #else // Code which shows all documents #end
How do I know when I am in the Main Space?
See http://platform.xwiki.org/xwiki/bin/view/DevGuide/Scripting#HBindings . You can get the current space from the current document. Hope this helps, Marius
-- View this message in context: http://xwiki.475771.n2.nabble.com/Get-current-space-velocity-tp7183403p71834... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
participants (3)
-
Florin Ciubotaru -
Hamster -
Marius Dumitru Florea