DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:searchformgoto

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:searchformgoto [2014-01-04 16:46] – [Discussion] goldseedplugin:searchformgoto [2023-05-30 18:55] (current) – removed nerun
Line 1: Line 1:
-====== searchformgoto plugin ====== 
- 
----- plugin ---- 
-description: A plugin for DokuWiki which allows adding a "Go" button to the search form that will go directly to a page if the search exactly matches a page name. Otherwise operates as a normal search. 
-author     : Payton Swick 
-email      : payton <at> foolord <dot> com 
-type       : action 
-lastupdate : 2014-01-04 
-compatible :  "Binky" 
-depends    :  
-conflicts  
-similar    :  
-tags       : search, redirect 
-downloadurl: http://vaslor.net/_media/tech/searchformgoto.tar 
----- 
- 
-^ Download | [[http://vaslor.net/_media/tech/searchformgoto.tar|searchformgoto.tar]] | 
- 
-===== How to use ===== 
- 
- 
- 
-You have to modify your template to use this plugin.  Edit <dokuwiki home>/lib/tpl/<your template>/main.php and replace the line: 
- 
-<code php> 
-<?php tpl_searchform() ?> 
-</code> 
- 
-With: 
- 
-<code php> 
-<?php if (!plugin_isdisabled('searchformgoto')) { 
- $searchformgoto = &plugin_load('helper','searchformgoto'); 
- $searchformgoto->gotoform(); 
- } else { tpl_searchform(); } 
-?> 
-</code> 
- 
-===== Download and Installation ===== 
- 
-Download and install the plugin using the [[plugin:plugin|Plugin Manager]] using the following URL. Refer to [[:Plugins]] on how to install plugins manually. 
- 
-  * <del>http://launchpad.net/searchformgoto/trunk/2009-03-02/+download/searchformgoto.tar.gz</del> 
-  * http://vaslor.net/_media/tech/searchformgoto.tar 
- 
- 
-===== Change log ===== 
- 
-  *  danny0838's solution was integrated and Korean translation was added. --- [[user>goldseed|S.C. Yoo]] //2014/01/04 16:34// 
- 
- 
-===== Discussion ===== 
- 
-----  
-** As of right now this doesn't work with a fresh install? ** 
-<code> 
-Fatal error: Call to undefined function tpl_gotoform() 
-</code> 
- 
-> I can't do it, not call tpl_gotoform with plugin installed 
-> Is there other TODO ? 
- 
->> I'm not sure I understand your problem.  It works fine in the installs I've done.  Can you describe your issue in more detail?  -Payton 
- 
----- 
- 
- 
-> I'd love to use this plugin, but the template I'm using (Monobook) uses a different piece of script for the search bar. I'm comfortable enough with searching and replacing lines of code when necessary, but I'm a newbie and *adapting* code is a little beyond me. Is there any way to turn the following searchform code into something that also works with your plugin? 
- 
-<code php> 
-> <?php if (tpl_getConf('mb_use_search')) { ?> 
-><div id="p-search" class="portlet"> 
->    <h5> 
->        <label><?php echo $lang['monobook_bar_search']?></label></h5> 
->    <div class="pBody"> 
->        <form action="<?php echo DOKU_BASE.DOKU_SCRIPT;?>" accept-charset="utf-8" id="dw__search" name="search"> 
->            <input type="hidden" name="do" value="search" /> 
->            <input id="qsearch__in" name="id" type="text" accesskey="f" value="" /> 
->            <input type='button' class="searchButton" id="searchGoButton" value="<?php echo >$lang['monobook_btn_go']?>" onclick="document.location.href='<?php echo DOKU_BASE.DOKU_SCRIPT;?>?id=' + >document.search.qsearch__in.value;" />&nbsp; 
->            <input type='submit' name="fulltext" class="searchButton" value="<?php echo >$lang['monobook_btn_search']?>" /> 
->        </form> 
->    </div> 
-></div> 
-</code> 
- 
->Sorry if this is a dumb question. Thanks in advance! 
->Alan Gratz 
- 
->> Hm.  It looks like that template defines its own search form entirely.  I'm not entirely sure what that template is doing with the form, but here's two suggestions to try: 
->> 1. Replace **all** of the above code within the <div> tags with 'tpl_gotoform();' 
->> 2. [This one might be better] Add the following lines near the end of your template form (you may need to remove the hidden "do" input you already have): 
-<code>          
-<input type="hidden" name="do" value="goto" /> 
-<input type="hidden" name="current_ns" value="'.$ns.'" /> 
-<input type="submit" value="'.$lang['btn_go'].'" class="button" name="goto" title="'.$lang['btn_go'].'" /> 
-</code> 
--Payton 
- 
----- 
-Unfortunately, I get "undefined function tpl_gotoform" with the "simple" template. 
- 
-Thanks,\\ 
-Kingsley 
- 
- 
-For the issue of **undefined function tpl_gotoform** a little patch could be done: 
- 
-  * Delete line 35, and 38-63 in action.php: 
- 
-<code php line-35> 
-        $contr->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'handle_act_render', array()); 
-</code> 
- 
-<code php line-38-63> 
-    function handle_act_render(&$event, $param) { 
-    ... 
-    } 
-</code> 
- 
-  * Add a file helper.php: 
- 
-<code php helper.php> 
-<?php 
-/** 
- * Searchformgoto Plugin 
- * 
- * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html) 
- * @author     Payton Swick <payton (at) foolord (dot) com> 
- */ 
- 
-// must be run within Dokuwiki 
-if(!defined('DOKU_INC')) die(); 
- 
-class helper_plugin_searchformgoto extends DokuWiki_Plugin { 
- 
-    function gotoform($ajax=true,$autocomplete=true) {   
-        global $lang; 
-        global $ACT; 
-        global $ID; 
-        // don't print the search form if search action has been disabled   
-        if (!actionOk('search')) return false; 
- 
-        print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">'; 
-        print '<input type="hidden" name="do" value="goto" />'; 
-        print '<input type="hidden" name="current_ns" value="'.cleanID(getNS($ID)).'" />';   
-        print '<input type="text" '; 
-        if($ACT == 'search') print 'value="'.htmlspecialchars($_REQUEST['id']).'" ';   
-        if(!$autocomplete) print 'autocomplete="off" '; 
-        print 'id="qsearch__in" accesskey="f" name="id" class="edit" title="[F]" />';   
-        print '<input type="submit" value="'.$this->getLang('btn_go').'" class="button" name="goto" title="'.$this->getLang('btn_go').'" />'; 
-        print '<input type="submit" value="'.$lang['btn_search'].'" class="button" name="goto" title="'.$lang['btn_search'].'" />'; 
-        if($ajax) print '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>'; 
-        print '</div></form>'; 
-        return true; 
-    }  
-} 
-</code> 
- 
-  * Write this in the template where you want to display the search box (commonly replace tpl_searchform()): 
- 
-<code php> 
-<?php if (!plugin_isdisabled('searchformgoto')) { 
- $searchformgoto = &plugin_load('helper','searchformgoto'); 
- $searchformgoto->gotoform(); 
- } else { tpl_searchform(); } 
-?> 
-</code> 
- 
- --- danny0838 //2010/12/27 13:32// 
- 
- 
-thanks danny0838!!! 
- 
- --- [[user>goldseed|S.C. Yoo]] //2014/01/04 16:45// 
  
plugin/searchformgoto.1388850374.txt.gz · Last modified: 2014-01-04 16:46 by goldseed

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