在Google Search Appliance中使用GET / POST方法时如何进行分页以进行查询

时间:2015-08-12 14:50:20

标签: wordpress pagination search-engine

我正在使用GET / POST方法将Google Search Appliance的结果嵌入到WordPress页面的iFrame中。第一页结果显示正常,但是当您尝试分页到其他页面时,查询将从结果显示中删除,因此第2页显示不相关的搜索结果。

以下是将结果嵌入我的WordPress页面模板的代码:

<?php

function showForm(){
    //echo "<form action=\"http://example.com/search-results\" method=\"post\">";
    //echo "<input id=\"searchform\" type=\"text\" name=\"q\" style=\"display: inline-block; width: 450px;\">";
    //echo "<input class=\"btn btn-primary\" type=\"submit\" value=\"Search\" name=\"btnG\">";
    //echo "</form>";
}

if (!empty($_POST['q'])) {
$searchClient = "WWW_frontend";
$searchOutput = "xml_no_dtd";
$searchSheet = "WWW_frontend";
$searchQuery = $_POST['q'];

echo "<p class=\"monospace\" style=\"margin-bottom: 10px; padding-bottom: 0px;\">You searched for: <b>".$searchQuery."</b></p>";

echo "<iframe id=\"_search-results\" seamless=\"seamless\" scrolling=\"no\" style=\"width: 100%; border: none; height: 1200px;\" name=\"_search-results\" src=\"http://example.com/search?q=$searchQuery&client=$searchClient&output=$searchOutput&proxystylesheet=$searchSheet&proxyreload=1\"></iframe>";

}else{
echo "<p>Nothing found! Please try your search again.</p>";
showForm();
}
?>

0 个答案:

没有答案