[xwiki-users] Conditional transclusion
I have these main documents which I want to consist of a bunch of "subdocuments", which are included/transcluded (own context, so I'll use Display, I guess). Main | -> A | -> B This document has two versions, New and Old: Main_New | -> A_new | -> B_new Main_Old | -> A_old | -> B_old Which is all fine as long as there exists New documents. Now to the finicky part. In some cases, there will be no "new" document for B. I then want this to happen: Main_New | -> A_new | -> B_old Main_Old | -> A_old | -> B_old So, I want the Main document to include a sub-document of it's own type if it exists, and if not, it should pick the "older" document. The selection is based on the "main" documents properties. (Note: I'm having actual new/old documents, so it's not versions of the same document. Also, I have simplified my example a bit, the real case has multiple levels of inclusion. ) Q: How do I go about creating a good conditional inclusion?
You can use the Velocity macro, http://extensions.xwiki.org/xwiki/bin/view/Extension/Velocity+Macro#HExample... , and you can check if the old version exists with $xwiki.exists($oldDocReference), see http://nexus.xwiki.org/nexus/service/local/repositories/releases/archive/org... . Hope this helps, Marius On Tue, Dec 10, 2013 at 4:08 PM, Aye Jaye <aye.jaye@outlook.com> wrote:
I have these main documents which I want to consist of a bunch of "subdocuments", which are included/transcluded (own context, so I'll use Display, I guess). Main | -> A | -> B This document has two versions, New and Old: Main_New | -> A_new | -> B_new Main_Old | -> A_old | -> B_old Which is all fine as long as there exists New documents. Now to the finicky part. In some cases, there will be no "new" document for B. I then want this to happen: Main_New | -> A_new | -> B_old Main_Old | -> A_old | -> B_old So, I want the Main document to include a sub-document of it's own type if it exists, and if not, it should pick the "older" document. The selection is based on the "main" documents properties. (Note: I'm having actual new/old documents, so it's not versions of the same document. Also, I have simplified my example a bit, the real case has multiple levels of inclusion. ) Q: How do I go about creating a good conditional inclusion?
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Thank you. That answers my question. I will look into the scripting macros. I suspect Groovy would give a similar experience. BTW: I have been trying a few things out with includes, and I am rather annoyed at the inability of accessing the included part and editing it from including page. If I edit an including page all I get is the include macros. Which makes sense in a way, but in MediaWiki you can get around it by having section editing of headings that bring you to the actual page... Section editing does not seem to anything of worth in XWiki. I can probably rig a solution with navigation structures where you click to access the included page(s), but holy major annoyance, Batman. Anyway, thanks for replying.
Date: Wed, 11 Dec 2013 23:02:03 +0200 From: mariusdumitru.florea@xwiki.com To: users@xwiki.org Subject: Re: [xwiki-users] Conditional transclusion
You can use the Velocity macro, http://extensions.xwiki.org/xwiki/bin/view/Extension/Velocity+Macro#HExample... , and you can check if the old version exists with $xwiki.exists($oldDocReference), see http://nexus.xwiki.org/nexus/service/local/repositories/releases/archive/org...
participants (2)
-
Aye Jaye -
Marius Dumitru Florea