Hello,
I applied exactly the solution proposed by Brian in my Wiki (see his answer below) : create macros in a specific wiki document, import it with an #includeMacros macro located inside the "View" field of my skin, like this:
###
### Main "view" template
###
### General wrapper for view actions
###
[.......]
</div>## main
#template("endpage.vm")
#includeMacros('XWiki.MyMacros')
#end
My problem is that the macro includeMacros adds {pre} / {/pre} tags that get rendered, and so appear in all pages. I cannot put them inside the "content" of the page, because I would have to overload the "contentview.vm" file, in which is declared the "xwikicontent" div.
How can I get rid of those {pre} {/pre} tags ? I would like to avoid overloading the "contentview.vm" because I think it's not a good thing to do (it's not in the default templates, but in the skins) ...
Thanks,
Jérémie
To expand on Thomas's second option, you can actually put either the macro definition or a directive including the document containing it into the view template of your skin (to make it global as you desired). This can be done either by modifying /templates/view.vm or the "view" field of your skin (which, if non-empty, will override view.vm).
And to clarify his reply slightly, the original macros.vm is actually in the /templates directory. If you wish your macro to be global, regardless of the skin, I think you will want to edit that one instead of the one in your skin directory. This is apparently a change from the pre-1.0 days, when the skins directories didn't contain template files - I presume that they are now copied there from /templates when a skin is created.
Vincent (or anybody), can you confirm this? Are these files actually copied whenever a skin is created, or only when a custom version of the file's content is desired?
Also, as Vincent mentions in an intervening reply, you can load macros from an XWiki document rather than from a file, using the #includeMacros macro (which, in 0.9.8
brain[sic]
From what I understand, there's two ways to do it. One, add it to macros.vm in your skin directory. Two, put it in a .vm file you include in the document you need to use it in (using #template("filename.vm")). Anyone know if there any better ways?
-Tom
--
Tom Kliethermes
eSupport Initiatives
IBM Information Management
(913) 599-7240 Fax: (913) 599-8590
http://www.ibm.com/software/data
Hi
How can I create my own macro in my xwiki (say, a macro for adding two numbers). Where should I write it. So that I can use it from any page ?
Regards
Roopesh
--
You receive this message as a subscriber of the xwiki-users@objectweb.org mailing list.
To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws