+ Reply to Thread
Results 1 to 7 of 7

Thread: strange behavior with a script

  1. #1

    Question strange behavior with a script

    I've got a script i'm using on a few pages that is supposed to match its title somewhere in the body of one of the sub pages and put each page title in a list that it exists on.

    so far it is doing that however it will list some pages 2-3 times and im lost as to why, could the pages have an alias that i don't see?
    This is version 10.1 running on Windows Server 2008
    Code:
    // page title has to be the hostname of the robot
    var filterRobot = page.title;
    
    // searches subpages of the app list 
    var reportArea= wiki.getpage("Software_Documentation/Network_Services/Monitoring/Compuware_Vantage/Active_User_Monitoring/Active_Monitored_Applications_List");
    
    // initializes subpages array
    var reportPagePathList = [];
    
    <ul>
    // Iterate through every subpage of the reportArea page
    foreach (var reportPage in reportArea.subpages) {
       if ( string.match(reportpage.text, filterRobot)){
       let reportPagePathList ..= [ reportPage.path ];
      }
    
    // Go through each page in turn
    foreach(var pagePath in reportPagePathList) {
    
     // Display a link to page
     <li> wiki.link(pagePath); </li>
     }
    }
    </ul>
    Last edited by adavid; 01-30-2012 at 08:49 PM. Reason: added version info

  2. #2
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    That is indeed a very interesting problem.

    Can you share the output of the following script:
    Code:
    web.pre([ p.path foreach var p in page.subpages  ]);
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

  3. #3

    Default

    Ive done that and im only seeing the three pages that should be there

    Code:
    [ 
        "Software_Documentation/Network_Services/Monitoring/Compuware_Vantage/Active_User_Monitoring/Active_User_Monitoring_Applications_List/CPACS", 
        "Software_Documentation/Network_Services/Monitoring/Compuware_Vantage/Active_User_Monitoring/Active_User_Monitoring_Applications_List/Lawson", 
        "Software_Documentation/Network_Services/Monitoring/Compuware_Vantage/Active_User_Monitoring/Active_User_Monitoring_Applications_List/Synapse"
    ]

  4. #4
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    That seems really weird. I don't understand why your initial problem that would be happening. The above output is exactly what I would expect and it looks perfectly fine.

    Can you still reproduce this issue?
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

  5. #5

    Default

    yeah, its still happening. the number of times it lists a page seems to be consistent with the page itself but not as a whole, so i may see page1 listed 5 times where page 1 is listed once. is it possible that it is following some hidden references from where i may have moved or renamed pages?

  6. #6
    Join Date
    Mar 2008
    Posts
    1,634

    Default

    I'd try generating the output inside the main loop and see what happens first. This does not yet try to explain *why* your problem is happening, but maybe it'll shed a little light. In other words:
    Code:
    // page title has to be the hostname of the robot
    var filterRobot = page.title;
    
    // searches subpages of the app list 
    var reportArea= wiki.getpage("Software_Documentation/Network_Services/Monitoring/Compuware_Vantage/Active_User_Monitoring/Active_Monitored_Applications_List");
    
    // initializes subpages array
    var reportPagePathList = [];
    
    <ul>
    // Iterate through every subpage of the reportArea page
    foreach (var reportPage in reportArea.subpages) {
       if ( string.match(reportPage.text, filterRobot)){
         <li> wiki.link(reportPage.path); </li>;
       }
      }
    </ul>

  7. #7

    Default

    That works fine, thanks for the help.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts