Issuepedia talk:Code/lib/links

From Issuepedia
Jump to navigation Jump to search

Alternate version of ShowRecent which allows sorting by internal data:

<func ShowRecent max>
  <let name=idx />
  <let name=including val=1 />
  <for table="qryW3_Titles_Catgs" where="(cl_to='Data/links') AND (page_namespace=0)" name=pg hide>
    <let name=pg_title val="@row.pg.page_title" />
    <let name=idx inc />
    <load page=$pg_title />
    <call GetBrief />
    <let name=strIdx copy=data[Date] />
    <let name=strIdx append copy=idx /> strIdx must be unique; sorting not important
    <let name=recent.out index=$strIdx copy=links.out />
    <let name=links.out />
    <let name=data />
  </for>

  <let name=recent.out sort rev />
  <let name=links.rtn />
  <for array=recent.out index=key hide limit=$max>
    <let name=links.rtn append copy=recent.out[$key] />
  </for>
</func>
  • Unfortunately, this also requires loading all of the links, sorting them, and then only showing the first $max of them -- could be slow, could run out of memory if too many links.
  • Another method would be to load all the pages, just retrieve the sorting criterion, sort it, then retrieve (again) the data for only the pages actually needed and build the display list from that.
There are no threads on this page yet.