Drost-Tenfelde.de

Personal website of Jannes Drost-Tenfelde, resident bass trombone player at Cologne Concert Brass and Brass Band Merum

User Tools

Site Tools


Sidebar

General

Upcoming Events

  • Dutch Bass Trombone Open
    05 September 2014-08 September 2014
    The only exclusive bass trombone event of the world, with an excellent setup: Ben van Dijk, Denson Paul Pollard, Matyas Veer and Erik van Lier!!
    Location: Katwijk, Netherlands

  • CCB: Open Air
    14 September 2014 10:00-16:00

    Location: Bayenthal

Music

Media

IT

Additional

dokuwiki:tips_and_tricks:home

Change display of search results

Version: 2011-05-25 “Rincewind”

Using DokuWiki's standard tpl_searchform to add a search form to your website is quite useful. However, the results this form returns might not be what you want, since they display raw DokuWiki code, rather than rendered html.

Original Code

The code that outputs the search results is located in inc/html.php on line line 373.

if($num < FT_SNIPPET_NUMBER){ // create snippets for the first number of matches only
    print '<div class="search_snippet">'.ft_snippet($id,$regex).'</div>';
}

As you can see, the function outputs the result using the ft_snippet function, which is located in inc/fulltext.php on line 297.

If you wish to completely remove the snippts in the search results page, just comment out the print statement on line 373.

Code: Render Snippets

Change the original code to:

if($num < FT_SNIPPET_NUMBER){ // create snippets for the first number of matches only
    // Get the snippet
    $ft_snippet = ft_snippet( $id, $regex );
    // Get the instructions                   
    $instructions = p_get_instructions( $ft_snippet );
    // Render html
    $snippet = html_entity_decode( p_render('xhtml', $instructions, $info ) );
    // Remove all hyperlinks, since they are potentially broken)
    $snippet = preg_replace('#<a.*>(.*)</a>#isU', '$1',  $snippet);
    // Output the HTML
    print '<div class="search_snippet">'.$snippet.'</div>';
}

This code still uses the ft_snippet function, but takes the snippets and turns them into properly rendered HTML. Unfortunately, the ft_snippet function breaks the pages up in pieces, which might mean that certain links stop function. For this reason, all hyperlinks are removed from the rendered snippets.

Code: Display Complete Pages

Change the original code to:

if($num < FT_SNIPPET_NUMBER){ // create snippets for the first number of matches only
    // Get the instructions of the page
    $instructions = p_get_instructions( rawWiki( $id ) );
    // Render html
    $snippet = p_render('xhtml', $instructions, $info );
    // Output the HTML
    print '<div class="search_snippet">'.$snippet.'</div>';
}

This option allows you to display the complete page for every page. I personally think it is unwise to do this, but you could potentially use styles on div.search_result and span.search_cnt to only display the contents if the user hovers over the link.

dokuwiki/tips_and_tricks/home.txt · Last modified: 2013/01/22 22:40 (external edit)

Page Tools