www.gusucode.com > baigo CMS PHP开源网站管理系统 v1.2.2源码程序 > baigocms_v1.2.2/bg_core/lang/zh_CN/help/tpl/search.php
<?php return "<h3>搜索</h3> <p>文件名:<span class=\"text-primary\">search_show.tpl</span></p> <p> 用于显示搜索结果。 </p> <div class=\"panel panel-default\"> <div class=\"table-responsive\"> <table class=\"table\"> <thead> <tr> <th class=\"text-nowrap\">键名</th> <th class=\"text-nowrap\">类型</th> <th class=\"text-nowrap\">说明</th> <th>备注</th> </tr> </thead> <tbody> <tr> <td class=\"text-nowrap\">tplData.articleRows</td> <td class=\"text-nowrap\">array</td> <td class=\"text-nowrap\">文章列表</td> <td>搜索结果。详情请查看 <a href=\"{BG_URL_HELP}ctl.php?mod=tpl&act_get=article#articleRow\" target=\"_blank\">文章</a>。</td> </tr> <tr> <td class=\"text-nowrap\">tplData.search</td> <td class=\"text-nowrap\">array</td> <td class=\"text-nowrap\">搜索参数</td> <td>显示文章列表所需要的搜索参数,查看 <a href=\"#search\">tplData.search</a>。</td> </tr> <tr> <td class=\"text-nowrap\">tplData.customs</td> <td class=\"text-nowrap\">array</td> <td class=\"text-nowrap\">自定义字段搜索数组</td> <td>多维数组,格式为 <code>\"custom_自定义字段 ID\" => \"关键词\"</code>,多个自定义字段时的例子:<code>array(\"custom_2\" => \"关键词\", \"custom_5\" => \"关键词\")</code></td> </tr> <tr> <td class=\"text-nowrap\">tplData.query</td> <td class=\"text-nowrap\">string</td> <td class=\"text-nowrap\">搜索参数序列化字符串</td> <td>搜索参数序列化为字符串以后的结果。</td> </tr> <tr> <td class=\"text-nowrap\">tplData.pageRow</td> <td class=\"text-nowrap\">array</td> <td class=\"text-nowrap\">分页参数</td> <td>详情请查看 <a href=\"{BG_URL_HELP}ctl.php?mod=admin&act_get=page\">分页参数</a></td> </tr> </tbody> </table> </div> </div> <p> </p> <a name=\"search\"></a> <h4><code>{\$tplData.search}</code> 数组</h4> <p>显示文章列表所需要的搜索参数。</p> <div class=\"panel panel-default\"> <div class=\"table-responsive\"> <table class=\"table\"> <thead> <tr> <th class=\"text-nowrap\">键名</th> <th class=\"text-nowrap\">类型</th> <th class=\"text-nowrap\">说明</th> <th>备注</th> </tr> </thead> <tbody> <tr> <td class=\"text-nowrap\">key</td> <td class=\"text-nowrap\">string</td> <td class=\"text-nowrap\">搜索关键词</td> <td> </td> </tr> <tr> <td class=\"text-nowrap\">customs</td> <td class=\"text-nowrap\">string</td> <td class=\"text-nowrap\">自定义字段</td> <td> </td> </tr> <tr> <td class=\"text-nowrap\">cate_id</td> <td class=\"text-nowrap\">int</td> <td class=\"text-nowrap\">栏目 ID</td> <td> </td> </tr> <tr> <td class=\"text-nowrap\">urlRow</td> <td class=\"text-nowrap\">array</td> <td class=\"text-nowrap\">搜索 URL 数组</td> <td>search_url 为搜索 URL 地址,page_attach 为分页附加参数,主要用于分页。</td> </tr> </tbody> </table> </div> </div> <p> </p> <a name=\"request\"></a> <h4>搜索请求</h4> <p>以 GET 形式发起搜索请求,搜索 URL 根据 <a href=\"{BG_URL_HELP}ctl.php?mod=admin&act_get=opt#visit\">访问方式</a> 的设置不同而不同。</p> <div class=\"panel panel-default\"> <div class=\"table-responsive\"> <table class=\"table\"> <thead> <tr> <th class=\"text-nowrap\">访问方式</th> <th>URL</th> </tr> </thead> <tbody> <tr> <td class=\"text-nowrap\">默认</td> <td>./index.php?mod=search&act_get=show&key=关键词&customs=自定义字段&cate_id=栏目 ID</td> </tr> <tr> <td class=\"text-nowrap\">伪静态</td> <td>./search/key-关键词/customs-自定义字段/cate-栏目 ID</td> </tr> <tr> <td class=\"text-nowrap\">纯静态</td> <td>./search/key-关键词/customs-自定义字段/cate-栏目 ID</td> </tr> </tbody> </table> </div> </div> <p> </p> <a name=\"customs\"></a> <h4>自定义字段</h4> <p>关于上述表格中的 <mark>自定义字段</mark>,是指 baigo CMS 特有的用于自定义字段的字符串,其格式为 GET 查询串,例如 <code>2=关键词&5=关键词</code>,然后将查询串用 <mark>Base64</mark> 进行编码,最后将生成的字符串进行 URL 编码。</p> <p>在 HTML 页面中,建议使用 JavaScript 或 VBScript 以及 jQuery 等脚本将搜索内容序列化。</p> <p>关于 <mark>Base64</mark> 的编码方法,本系统内置一个 Base64 编码的 JavaScript 的插件,位于 ./bg_static/js/base64.js,只需在适当的地方载入该脚本,然后在需要进行 Base64 编码的地方使用函数 <code>Base64.encode(‘字符串’)</code> 即可,您还可在需要的时候,使用 <code>Base64.decode(‘Base64 字符串’)</code> 函数进行解码。</p> <p> </p> <h4>示例代码</h4> <p>HTML 表单</p> <p> <pre><code class=\"language-markup\"><form name="search" id="search"> <div class="form-group"> <label class="control-label">关键词</label> <input type="text" name="key" id="key" value="" class="form-control" placeholder="关键词"> </div> <div class="form-group"> <label class="control-label">电压</label> <input type="text" name="2" value="" class="customs form-control" placeholder="电压"> </div> <div class="form-group"> <label class="control-label">序列号</label> <input type="text" name="1" value="" class="customs form-control" placeholder="序列号"> </div> <button type="button" id="search_go" class="btn btn-primary">搜索</button> </form></code></pre> </p> <p>jQuery</p> <p> <pre><code class=\"language-javascript\">$(document).ready(function(){ $("#search_go").click(function(){ var _key = $("#key").val(); var _customs = $(".customs").serialize(); window.location.href = "./search/key-" + _key + "/customs-" + encodeURIComponent(Base64.encode(customs)) + "/"; }); })</code></pre> </p>";