[xwiki-users] Container macro with more than 2 columns
Hello, I have a weird issue with {{container}} macro in xwiki 4.5.2. If I want to display 3 columns, like this for example: {{container layoutStyle="columns"}} ((( a ))) ((( b ))) ((( c ))) {{/container}} It shows content over only 2 columns like this: a b c ... instead of expected: a b c After having a look at the source : https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-4.5.2/xwiki-plat... ... I think I understand the problem. It seems a limitation of container macro, is that it injects columns.css in the page with number of columns as parameter. So if you add more than one {{container}} to the same page, they can't have a different number of columns ... For instance in my case I used the container macro in a Panel, with 2 columns - so I can never add more than 2 columns in other locations. I removed the columns from the Panel, and now my 3-columns are correctly displayed :) If you agree I could fill a Jira for this (I searched quickly, didn't find it already described) Thanks, Jeremie
Hi Jeremie, I think it’s Anca who coded this container macro so I don’t know the details but it looks like a bug indeed. I’d file a jira issue if I were you since it seems like you nailed the problem :) Thanks -Vincent On 5 Mar 2014 at 16:55:30, Jeremie BOUSQUET ([email protected](mailto:[email protected])) wrote:
Hello,
I have a weird issue with {{container}} macro in xwiki 4.5.2. If I want to display 3 columns, like this for example:
{{container layoutStyle="columns"}} ((( a ))) ((( b ))) ((( c ))) {{/container}}
It shows content over only 2 columns like this: a b c
... instead of expected: a b c
After having a look at the source : https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-4.5.2/xwiki-plat...
... I think I understand the problem. It seems a limitation of container macro, is that it injects columns.css in the page with number of columns as parameter. So if you add more than one {{container}} to the same page, they can't have a different number of columns ... For instance in my case I used the container macro in a Panel, with 2 columns - so I can never add more than 2 columns in other locations. I removed the columns from the Panel, and now my 3-columns are correctly displayed :)
If you agree I could fill a Jira for this (I searched quickly, didn't find it already described)
Thanks, Jeremie _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Thanks Vincent, I created a JIRA for it: http://jira.xwiki.org/browse/XWIKI-10118 I nailed the problem maybe, but I didn't nail the solution :) Doesn't seem so easy ... BR, jeremie 2014-03-05 17:03 GMT+01:00 [email protected] <[email protected]>:
Hi Jeremie,
I think it's Anca who coded this container macro so I don't know the details but it looks like a bug indeed.
I'd file a jira issue if I were you since it seems like you nailed the problem :)
Thanks -Vincent
On 5 Mar 2014 at 16:55:30, Jeremie BOUSQUET ([email protected] (mailto:[email protected])) wrote:
Hello,
I have a weird issue with {{container}} macro in xwiki 4.5.2. If I want to display 3 columns, like this for example:
{{container layoutStyle="columns"}} ((( a ))) ((( b ))) ((( c ))) {{/container}}
It shows content over only 2 columns like this: a b c
... instead of expected: a b c
After having a look at the source :
https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-4.5.2/xwiki-plat...
... I think I understand the problem. It seems a limitation of container macro, is that it injects columns.css
in
the page with number of columns as parameter. So if you add more than one {{container}} to the same page, they can't have a different number of columns ... For instance in my case I used the container macro in a Panel, with 2 columns - so I can never add more than 2 columns in other locations. I removed the columns from the Panel, and now my 3-columns are correctly displayed :)
If you agree I could fill a Jira for this (I searched quickly, didn't find it already described)
Thanks, Jeremie _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Hello, I don't know if it is the place to discuss issues, or if I should put the following as comment of the issue in jira, but ... I can put it afterwards in jira. I thought about it, and imagined that only way around, would be to assign a different "id" to the column elements added by each different {{container}} macro. For example the following: {{container}} ...3 columns... {{/container}} {{container}} ...2 columns... {{/container}} Would generate html : <div class="container-columns" id="container1"> ... columns... </div> <div class="container-columns" id="container2"> ...columns... </div> columns css would be injected twice with: ..../columns.css?columns=3&id=container1 ..../columns.css?columns=2&id=container2 (but I don't know if it's even possible to inject it twice with same name and different params as currently it's not the case) (*) In CSS column width would be computed from number of columns, and selector changed to: #${request.id}.container-columns .column { ...} WDYT ? 2 problems I see are: - point (*) above - generate automatically an id for the container (and how ?) like "containerN", or force passing a new parameter "id" to the container macro (or maybe syntax (% id=... %) could work ?) BR, Jeremie 2014-03-05 17:25 GMT+01:00 Jeremie BOUSQUET <[email protected]>:
Thanks Vincent,
I created a JIRA for it: http://jira.xwiki.org/browse/XWIKI-10118
I nailed the problem maybe, but I didn't nail the solution :) Doesn't seem so easy ...
BR, jeremie
2014-03-05 17:03 GMT+01:00 [email protected] <[email protected]>:
Hi Jeremie,
I think it's Anca who coded this container macro so I don't know the details but it looks like a bug indeed.
I'd file a jira issue if I were you since it seems like you nailed the problem :)
Thanks -Vincent
On 5 Mar 2014 at 16:55:30, Jeremie BOUSQUET ([email protected] (mailto:[email protected])) wrote:
Hello,
I have a weird issue with {{container}} macro in xwiki 4.5.2. If I want to display 3 columns, like this for example:
{{container layoutStyle="columns"}} ((( a ))) ((( b ))) ((( c ))) {{/container}}
It shows content over only 2 columns like this: a b c
... instead of expected: a b c
After having a look at the source :
https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-4.5.2/xwiki-plat...
... I think I understand the problem. It seems a limitation of container macro, is that it injects
columns.css in
the page with number of columns as parameter. So if you add more than one {{container}} to the same page, they can't have a different number of columns ... For instance in my case I used the container macro in a Panel, with 2 columns - so I can never add more than 2 columns in other locations. I removed the columns from the Panel, and now my 3-columns are correctly displayed :)
If you agree I could fill a Jira for this (I searched quickly, didn't find it already described)
Thanks, Jeremie _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Jerem, Nice to see someone else with the same problem we had :-) I run into this problem when I added a custom macro which displayed a TOC on a page in multiple columns. The user can choose how many columns the TOC should have (for example 3), and the TOC would show all child-pages in 3 columns. But when I added my macro to our dashboard, I noticed that the number of columns was being ignored. Reason: the dashboard is using the {{container}} macro to display the columns in the dashboard. It turns out that an XWiki page is listening to only 1 {{container}} macro (and thus ignored my custom macro). I do have a solution for you...use a different macro! We are now using the Column Macro <http://extensions.xwiki.org/xwiki/bin/view/Extension/Column+Macro> . {{section}} {{column}} a {{/column}} {{column}} b {{/column}} {{column}} c {{/column}} {{/section}} Hope this helps! -- View this message in context: http://xwiki.475771.n2.nabble.com/Container-macro-with-more-than-2-columns-t... Sent from the XWiki- Users mailing list archive at Nabble.com.
This is the Velocity we use in our "JAZO TOC": {{velocity}} #macro(createTOCTree $document $column_nr) #set($translated = $document.getTranslatedDocument()) #set($name = $translated.getName()) #set($fullname = $translated.getFullName()) #set($prefixed = $translated.getPrefixedFullName()) #set($where = "where doc.parent = '$name' or doc.parent = '$fullname' or doc.parent = '$prefixed' order by doc.name") #if ($name == "WebHome") #set($space = $document.getSpace()) #set($where = "where doc.space = '$space' and (doc.parent = '' or doc.parent = '$name' or doc.parent = '$fullname' or doc.parent = '$prefixed') and doc.name != 'WebHome' and doc.name != 'WebPreferences' order by doc.name") #end #set($pages_count = 0) #foreach($name in $xwiki.searchDocuments($where)) #set($pages_count = $pages_count + 1) #end ##Er zijn $pages_count links #set($max_links = $mathtool.ceil($mathtool.div($pages_count,$mathtool.toInteger($column_nr)))) {{section}} {{column}} #foreach($name in $xwiki.searchDocuments($where)) #if ($xwiki.getDocument($name)) #set($document = $xwiki.getDocument($name)) #set($translated = $document.getTranslatedDocument()) #set($prefixed = $translated.getPrefixedFullName()) #set($title = $translated.getDisplayTitle()) [[$title>>$prefixed]] #if ($foreach.count % $max_links == 0 && $foreach.last == false) {{/column}} {{column}} #end #end #end {{/column}} {{/section}} #end #set($column_count=$xcontext.macro.params.Columns) #set($my_document=$xcontext.macro.params.Document) ##**Table Of Contents** #if ("$!my_document"=="") ---- #createTOCTree($doc $column_count) ---- #else [[**$xwiki.getDocument($my_document).getTranslatedDocument().getDisplayTitle()**>>$xwiki.getDocument($my_document)]] ---- #createTOCTree($xwiki.getDocument($my_document) $column_count) ---- #end {{/velocity}} It required two parameters, "Columns" (requried) and "Document" (optional). The "Columns" parameter is used to define the number of columns (obviously). The "Document" is optional, if empty the macro will show the TOC of the current page, otherwise it will display the TOC of specified document. This way, our users can create a "main TOC". -- View this message in context: http://xwiki.475771.n2.nabble.com/Container-macro-with-more-than-2-columns-t... Sent from the XWiki- Users mailing list archive at Nabble.com.
Thanks, In fact I forgot about the section / column macros, I used them some years ago, before replacing them with container macro (as it's bundled in xwiki while section/column macros are retired). I see why it didn't have this problem, it's because it was using inline styles - so no pb with css injection... I may use this as a temporary workaround though, so thanks again, BR, Jeremie 2014-03-07 11:39 GMT+01:00 Hamster <[email protected]>:
Jerem,
Nice to see someone else with the same problem we had :-)
I run into this problem when I added a custom macro which displayed a TOC on a page in multiple columns. The user can choose how many columns the TOC should have (for example 3), and the TOC would show all child-pages in 3 columns.
But when I added my macro to our dashboard, I noticed that the number of columns was being ignored. Reason: the dashboard is using the {{container}} macro to display the columns in the dashboard. It turns out that an XWiki page is listening to only 1 {{container}} macro (and thus ignored my custom macro).
I do have a solution for you...use a different macro!
We are now using the Column Macro <http://extensions.xwiki.org/xwiki/bin/view/Extension/Column+Macro> .
{{section}} {{column}} a {{/column}}
{{column}} b {{/column}}
{{column}} c {{/column}} {{/section}}
Hope this helps!
-- View this message in context: http://xwiki.475771.n2.nabble.com/Container-macro-with-more-than-2-columns-t... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (3)
-
Hamster -
Jeremie BOUSQUET -
vincent@massol.net