Tags:
create new tag
view all tags

SID-01376: Extract certain data/content from topic

Status: Answered Answered TWiki version: 4.2.3 Perl version: 5.2
Category: CategorySearch Server OS: Linux Last update: 13 years ago

Hello,

I would like to perform a SEARCH on TOPICONE, that should display the result of CALC function in TOPICTWO.

For example:

  • In TOPICTWO i have the following line:
    %STARTSECTION{name="PerProduct" type="section"}% %CALC{"$SUM( $ABOVE() )"}% %ENDSECTION{name="PerProduct" type="section"}%

  • In TOPICONE i wish to run the following line:
    %SEARCH{ "TOPICTWO" web="Sandbox" scope="topic" nosearch="on" nototal="on" header=" | Availability Management | Total Time Overall | " format=" | Per Product | %INCLUDE{"TOPICTWO" section="PerProduct"}% " }%

-- AlinGramescu - 2012-01-13

Discussion and Answer

This won't work because an INCLUDE only includes the source of specified section, not the result. That is, the CALC will not see the rows above.

You need to include the whole table to do the CALC. That included section can be hidden in HTML comments or a hidden div. See SpreadSheetRollupTest for inspiration.

The SetGetPlugin also comes in handy. Options:

  • Remember the values temporarily when including content as a hidden table
  • Remember persistently in the first topic, so that you can read the value in any other topic without an INCLUDE.

-- PeterThoeny - 2012-01-13

For more sophisticated applications I recommend to create TWikiForms based apps. This makes reporting much more flexible. See tutorial.

-- PeterThoeny - 2012-01-13

Thank you very much Mr. Peter.

One last question (i hope).. Because i have several topics (with a common taxonomy format), with the same tables, but different values, can i run a search thru these topics to have them displayed into a single topic (and maybe hidden), after i will proceed with the CALC function to get a total of the values as you've indicated above?

-- AlinGramescu - 2012-01-16

Yes, and if needed you can get separate tables per web by using a footer="" that has the SET or CALC and 2 or more newlines to separate the table.

-- PeterThoeny - 2012-01-16

Thank you Mr. Peter, i found this to be very helpful, but still i have one problem.

How should the search command look to display me all the sections (section="title") from all the existing topics (that start with "TopicOne").

I've tried: %SEARCH{ "TopicOne" web="%WEB%" scope="text" type="regex" nosearch="on" nototal="on" multiple="on" format=" %INCLUDE{"$topic" section="title"}% " }%

-- AlinGramescu - 2012-01-17

Mr. Peter,

I have succeeded finding a way to do a search that display the entire table and show the result of the CALC function, but i think it's not properly written.

%SEARCH{ "Topic" web="%WEB%" scope="text" type="regex" nosearch="on" nototal="on" limit="1" format="%INCLUDE{ "TopicTwo" section="PerProduct" }%" footer="<!-- %CALC{"$GET( grandtotal )"}% -->" }%

In TopicTwo i have the following: %STARTSECTION{name="PerProduct" type="section"}%

Worked Hours Product Name
640 Infrastructure
67.5 SPG
1.5 Web
%CALC{"$SUM( $ABOVE() )"}% %CALC{"$SET( grandtotal, $EVAL( $GET( grandtotal ) + $SUM($ABOVE()) ) )"}% Sum of all products
%ENDSECTION{name="PerProduct" type="section"}%

Still, there is one problem, it is showing me the same table result 6 times, which actually is the total number of topics that exist with the searched taxonomy ("Topic"). How can i display this only once, for the topic that actually have the included format.

Thank you in advance.

-- AlinGramescu - 2012-01-17

Mr. Peter, Sorry, for asking you again, but can you help me with this?

What shall i do for this to work ? : %SEARCH{ "Topic" web="%WEB%" scope="topic" type="regex" nosearch="on" nototal="on" format="%INCLUDE{ "$topic" section="PerProduct" }%" footer="<!-- %CALC{"$GET( grandtotal )"}% -->" }%

Thank you.

-- AlinGramescu - 2012-01-19

Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the TWiki consultants if you need timely help. We invite you to get involved with the community, it is more likely you get community support if you support the open source project!

-- PeterThoeny - 2012-07-01

      Change status to:
ALERT! 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.
SupportForm
Status Answered
Title Extract certain data/content from topic
SupportCategory CategorySearch
TWiki version 4.2.3
Server OS Linux
Web server Apache 3.0
Perl version 5.2
Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2012-07-01 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.