Search:
Template:MindTouch > ToBeDeveloped > Template:RecordSearch

Template:RecordSearch

    Table of contents
    No headers
    // + PARAMETERS
    var par = { 
        srcpath: ( __request.args.srcpath ?? args.srcpath ..'/*' ),
        search_criteria: __request.args.search_criteria ?? args.search_criteria ??  '',
        tsfilter: __request.args.tsfilter ?? args.tsfilter ?? null, // Add TSTable filter and what, it just passes this data to the filter parameter of TSTable
        columns:  __request.args.columns ?? args.columns ??  [], // Wich data columns to show on TSTable Format
        data_id: (__request.args.data_id ?? args.data_id ?? ''), // Table ID with data
        new_table_id: (__request.args.new_table_id ?? args.new_table_id ?? 'rs_record_list'), // The generated Table ID
        column_link_record: (__request.args.column_link_record ?? args.column_link_record), // What columns links to the original data page
        filter_tags: (__request.args.filter_tags ?? args.filter_tags ?? []), // Tags that you don't want to show
        ajax_action: String.tolower( __request.args.ajax_action ?? args.ajax_action ?? 'load')
       };
    
    if ((par.ajax_action=='load') || (par.ajax_action=='reload_RecordSearch')) {
     var search_criteria = par.search_criteria;
     if (par.srcpath != '/*') {
         let search_criteria ..= " AND path: " ..string.replace(par.srcpath, 'User:','User\\:');
       }
    
     var id = par.data_id;
     if (id is str && #id) { let id = "//table[@id='"..id.."']"; } else  { let id = './/table'; } var record;
     var record_list = [];
     var special_tags = "";
     var x,tbl;
     var RX = ".//tr";
     var CX = ".//td | .//th";
    
     foreach(var p in wiki.getsearch(search_criteria, 1000, 'title')) {
        // -- For performance reasons include TableParse.KeyValue here
        //    let record = TableParse.KeyValue(p.xml,"text",id);
        let x = xml.select(p.xml, id);
        let tbl = [ [ string.trim("" .. xml.text(c)) foreach var c in r[CX] ] foreach var r in x[RX] ];
        let record = { (r[0]):(r[1] ?? {}) foreach var r in tbl };
        // ------------------------------------------------------------
    
        if (#record>0) {
          let record ..= { "page_tags": ( foreach(var tag in p.tags) 
                                           { 
                                            if(!List.Contains(par.filter_tags,tag.value)) {
                                                 <A HREF=("/Special:Tags?tag="..tag.value)>("["..tag.value.."]")</A><BR />
                                              }
                                           }
                                        ) };
          let record ..= { "page_title": p.title };
    
          let record ..= { (par.column_link_record): (web.link(p.uri,record[par.column_link_record])) };
         
    
          let record_list ..= [ record ];
         }
    
      }
    
     TSTable {
        options: { id: par.new_table_id, zebra:true, width:"100%", initial: [[0,0]] },
        columns: par.columns,
        filter: par.tsfilter,
        data: record_list
      };
    
    }
    
    

    Files (0)

     

    Comments (0)

    You must login to post a comment.