SID-00830: Using '%INCLUDE' to combine tables from different topics
| Status: |
Answered |
TWiki version: |
4.3.2 |
Perl version: |
5.008008 (linux) |
| Category: |
CategoryRendering |
Server OS: |
Linux 2.6.18-53.1.14.el5pae (i386-linux-thread-multi) |
Last update: |
16 years ago |
Hi Guys,
I have a fairly specific user requirement which I've been having trouble with and I'm not sure if it's possible to achieve in TWiki.
The user maintains tables (to-do lists) on different topic pages depending on the project. Each table has the exact same columns and tracks things like start & end date, status, etc. so these can be sorted on.
The manager would like a topic page where all the to-do lists from the different topics are combined into a single table, so sorting can be done globally across all the to-do entries from the different projects. I.e. they want to be able to see a single list containing all to-do entries and be able to sort across all of it.
I've tried to use the '%INCLUDE' statement, and it works to pull in the tables, but it inserts them separately and not as a single continuous table.
As an example, I've created the following two topics containing tables:
-
http://www.chaosworld.com/wiki/bin/view/Sandbox/TableExample1
-
http://www.chaosworld.com/wiki/bin/view/Sandbox/TableExample2
..and have combined them on the following topic:
-
http://www.chaosworld.com/wiki/bin/view/Sandbox/TableMerge
In the 'Table Example 1 & 2' topics I use anchors to denote the start and end of the table I'm including, and using that as the start and end markers in my '%INCLUDE' regex's. The two includes are pasted below as a reference and, as you can see, I've tried to put them side by side in an effort to make them into a single table (I've also removed the table headers in the 2nd table through the regex).
%INCLUDE{"TableExample1" pattern="^.*#TableStart(.*?)#TableEnd.*"}%%INCLUDE{"TableExample1" pattern="^.*\| \*Start Date\* \| \*Task\* \| \*Assigned To\* \| \*Status\* \| \*End Date\* \|(.*?)#TableEnd.*"}%
Q: Is there any way to combine these separate tables into a single table?
Thanks very much in advance for any help - much appreciated!
PS: At this stage I only have the base installation with no additional Plug-ins installed. Also, wasn't 100% sure about how to Categorise this question - hope the one I chose makes sense.
--
JanRoos - 2010-05-10
Discussion and Answer
Look into
TWikiForms based applications with
FormattedSearch and
QuerySearch. Each project page would have a form attached; it is easy to run reports to pull data from the forms.
In your case the newline between the #anchors and table result in separate tables when you include them. As a workaround you can use a
multiple="on" search with
type="regex" to pull just the table rows from a page. Untested example:
%SEARCH{
search="^ *\|.*\| *$"
type="regex"
topic="TableExample*"
multiple="on"
nonoise="on"
format="$text"
}%
This will pull in all table rows. You can restrict it, for example to first column starting with a digit:
%SEARCH{
search="^ *\| *[0-9].*\| *$"
...
More at
VarSEARCH,
FormattedSearch,
RegularExpression
--
PeterThoeny - 2010-05-10
Peter,
Thanks a lot - that works an absolute treat! I never even considered using %SEARCH for this. I'll delve into the topics you've suggested.
I've got it up and running - client is super happy.
Cheers
Jan
--
JanRoos - 2010-05-10
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.