It's better when it's simple

User Tools

Site Tools


searchresults plugin

Compatible with DokuWiki

No compatibility info given!

plugin List of page links from search criteria

Last updated on

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with !discontinued, include, listing, search

By Todd Augsburger

:!: This plugin is discontinued as according to his website (2012-06-29) the author of this plugin died in 2011. Feel free to adopt the plugin. :!:

This syntax plugin is a plugin that inserts the results of a search as a bulleted list of links. The list is sorted alphanumerically (natsort), and uses the correct pagenames if $conf['useheading'] is set.


To produce normal [[page]] links to found pages:

{{search>the words}}
To produce [[page#section|pagename]] links to a specified section within found pages1)
{{search>the words|index}}

I actually removed this “section” capability in the latest release, since it wasn't particularly useful (to me) and conflicted with searches which had a “|” in their phrases. Is this important for anyone?

For instance, {{search>searchresults}} would list the found pages as:

while {{search>searchresults "== Syntax =="|Syntax}} would list this page as:


Removed, see above.


The plugin has no configuration settings.


Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Revision History

  • 2007-08-30 — Updated.
  • 2007-08-06 — Updated.
  • 2007-02-27 — Released.


 * @license    GPL 2 (
 * @author     Todd Augsburger <>
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
class syntax_plugin_searchresults extends DokuWiki_Syntax_Plugin {
    function getInfo(){
        return array(
            'author' => 'Todd Augsburger',
            'email'  => '',
            'date'   => '2007-08-06',
            'name'   => 'SearchResults Plugin',
            'desc'   => "returns search results as bulleted list:\n{{search>the words}} for normal [[page]] links\n{{search>the words|section}} for [[page#section|pagename]] links",
            'url'    => '',
    function getType() {
        return 'substition';
    function getSort() {
        return 300;
    function connectTo($mode) {
        $this->Lexer->addSpecialPattern("{{search>.*?}}", $mode, 'plugin_searchresults');
    function handle($match, $state, $pos, &$handler) {
        if ($state == DOKU_LEXER_SPECIAL) {
             // strip / from start and / from end
            $match = substr($match,9,-2);
            return array($state, $match);
        return array();
    //natsort an array of pagenames
    function _addSorted(&$target,$names){
      global $conf;
      if ($conf['useheading']) {
        // sort by headings
        $title_array = array();
        foreach($names as $key=>$value) {
          if ($title = p_get_first_heading($value))
            $title_array[$key] = $title;
            $title_array[$key] = $value;
        foreach($title_array as $key=>$value)
          $target[] = $names[$key];
      } else {
        // sort by pagenames
        foreach($names as $value)
          $target[] = $value;
    function render($mode, &$renderer, $data) {
        if ($mode == 'xhtml') {
            list($state, $match) = $data;
            if ($state == DOKU_LEXER_SPECIAL) {
              $matches = array();
                $search = ft_pageSearch($matches[1],$poswords);
                $search = ft_pageSearch($match,$poswords);
                $renderer->doc .= "<ul>\n";
                $key_array = array();
                foreach($key_array as $value) {
                  $renderer->doc .= '<li class="level1"><div class="li">';
                    $renderer->doc .= html_wikilink(':'.$value);
                    $renderer->doc .= html_wikilink(':'.$value.'#'.$matches[2],($title = p_get_first_heading($value)) ? $title : $value);
                  $renderer->doc .= "</div>\n";
                $renderer->doc .= "</ul>\n";
            return true;
        return false;


  • You may see the searchresults plugin in use (in a closed wiki) here where a folded list is presented.
    (Click on the “Composer”–the wiki syntax is {{search>"Lowell Mason" @cobs}})
  • Or in use (in an open wiki) here


Thanks for making this available. I got it installed and it mostly does what I want, but…

It seems to be missing:

Correct! I'll update the code.

Also, a few other things would be nice:

  • the search results don't update without setting the cache time to something short for the entire wiki; it would be nice if that wasn't necessary
I use the ~~NOCACHE~~ tag in pages which need to be updated “realtime”
  • it would be nice to be able to include/exclude namespaces
I use “@namespace” within my searches to limit them to a single namespace …
and do multiple searches for multiple criteria–that way it's not limited to just namespaces
  • it would be nice to be able to display the namespace in the search results
So, using the above, I put the namespaces or descriptions on the page. Tables work well, too.
  • it would be nice to be able to exclude specific pages
Agreed. My “work-around” is that I use another plugin which allows tags in the page, so my searches exclude certain tags
  • the page containing the search should probably always be excluded
Well, not always–I want my “lists” to be identical everywhere. But it might make a good option
  • it would be nice to be able to display context optionally
Good suggestion

Hi Todd. Superb plugin - it makes multiple relationships between pages really easy to do.

However, I WOULD like the section search facility. Why?

My site has lists of tunes, and I would like to link to tune authors.

But I do sometimes refer to the same people as playing those tunes. Obviously, this would cause doubles where I don't want them.

However, since I will put tune authors in a separate section, this would work.

Could you maybe just quote the necessary code here? I could then just paste it in and you would not need to do a new release.


Ed Bradburn

The original code (which included the ability to go to a section) is what is still shown above
Note that it did not “search” for the section, it simply allowed the section text to be specified and passed to the resultant HTML. i.e. …
{{search>the words|section}}

returned a link like


Todd Augsburger 2008-10-17

There is no error checking on whether these sections actually exist–this is most useful when the section are also part of the search criteria.
plugin/searchresults.txt · Last modified: 2018-06-05 23:09 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki