[xwiki-users] #includeMacros("macrosDocument")
Please, where must I include a #includeMacros macro to have the macros defined there available for any document in a wiki? I see the Macro Mapping field in Administration > Preferences > Advanced, but I am not able to find how to use it. I've tried by putting the macros there, the macro there calling a document with the macros' definition,.. but none of these worked. A modified macros.vm does perfect. Thanks for your help, Ricardo -- Ricardo Rodríguez Your EPEC Network ICT Team
[Ricardo Rodriguez] Your EPEC Network ICT Team wrote:
Please, where must I include a #includeMacros macro to have the macros defined there available for any document in a wiki?
I see the Macro Mapping field in Administration > Preferences > Advanced, but I am not able to find how to use it. I've tried by putting the macros there, the macro there calling a document with the macros' definition,.. but none of these worked. A modified macros.vm does perfect.
Thanks for your help,
Ricardo
If it doesn't have to be a wiki document, then the best thing to do is to write a mymacros.vm file, put it somewhere, like /skins/mymacros.vm, and register it in /WEB-INF/velocity.properties (search for macros.vm and append it there). -- Sergiu Dumitriu http://purl.org/net/sergiu/
Hi Ricardo,
Please, where must I include a #includeMacros macro to have the macros defined there available for any document in a wiki?
I see the Macro Mapping field in Administration > Preferences > Advanced, but I am not able to find how to use it. I've tried by putting the macros there, the macro there calling a document with the macros' definition,.. but none of these worked. A modified macros.vm does perfect.
First you need to put all your macros in one page, let's say XWiki.MyMacros. Then you'll have to go to the Administration, Tab Preferences, Line Advanced. Then put the name of your page in the Velocity Macro Pages field (you can put only one page there for performance reasons). So you'll have : Velocity Macro Pages : XWiki.MyMacros Then save the page. You can now call your macros from wherever in the wiki. Guillaume
Sergiu Dumitriu wrote:
If it doesn't have to be a wiki document, then the best thing to do is to write a mymacros.vm file, put it somewhere, like /skins/mymacros.vm, and register it in /WEB-INF/velocity.properties (search for macros.vm and append it there).
Thanks Sergiu. This surely works, but it will imply to keep track of a change done in another XWiki configuration file. Of course is not big deal to add it to xwiki.cfg and hibernate.cfg.xml that have to be changed after each update. I think the approach proposed by Guillaume avoid it. Is there any performance difference between both methods I must take into account? Thanks!! Ricardo -- Ricardo Rodríguez Your EPEC Network ICT Team
Guillaume Lerouge wrote:
First you need to put all your macros in one page, let's say XWiki.MyMacros . Then you'll have to go to the Administration, Tab Preferences, Line Advanced. Then put the name of your page in the Velocity Macro Pages field (you can put only one page there for performance reasons). So you'll have :
Velocity Macro Pages : XWiki.MyMacros
Then save the page. You can now call your macros from wherever in the wiki.
Thanks, Guillaume. It works fine. I was putting the document in the wrong method. Is it worth a FAQ entry? Are you aware of any performance difference between this approach and the one prosed by Sergiu? Cheers, Ricardo -- Ricardo Rodríguez Your EPEC Network ICT Team
[Ricardo Rodriguez] Your EPEC Network ICT Team wrote:
Guillaume Lerouge wrote:
First you need to put all your macros in one page, let's say XWiki.MyMacros . Then you'll have to go to the Administration, Tab Preferences, Line Advanced. Then put the name of your page in the Velocity Macro Pages field (you can put only one page there for performance reasons). So you'll have :
Velocity Macro Pages : XWiki.MyMacros
Then save the page. You can now call your macros from wherever in the wiki.
Thanks, Guillaume. It works fine. I was putting the document in the wrong method. Is it worth a FAQ entry?
Are you aware of any performance difference between this approach and the one prosed by Sergiu?
Just looked at the code to see how it works. Registering in velocity.properties causes the file to be parsed once when the platform starts. Registering in XWikiPreferences causes the file to be parsed for each line (!) of the parsed document. -- Sergiu Dumitriu http://purl.org/net/sergiu/
Sergiu Dumitriu wrote:
Just looked at the code to see how it works.
Registering in velocity.properties causes the file to be parsed once when the platform starts.
Registering in XWikiPreferences causes the file to be parsed for each line (!) of the parsed document.
Thanks!
Far clear! To look at the code is my main pending issue :-( Keep trying to survive with the help of the community, Ricardo -- Ricardo Rodríguez Your EPEC Network ICT Team
participants (3)
-
[Ricardo Rodriguez] Your EPEC Network ICT Team -
Guillaume Lerouge -
Sergiu Dumitriu