yourphp搜索代码
HTML代码
<form method="GET" action="index.php?"> //指向地址
<input type="hidden" id="" name="m" value="Search"/>
<select id="module" name="module" style="display:none"> //重点:获取模型
<option selected="selected" value="Product">产品模型
</option>
</select>
<div class="input01">
<input type="text" name="keyword" id="" class="input-text" value="" /> //关键词
</div><div class="button01">
<input type="image" src="/yt/Yourphp/Tpl/Home/new/Public/images/button01.jpg" />
</div>
</form>
php代码 \Yourphp\Lib\Action\Home\SearchAction.class.php
<?php
/**
*
* SearchAction.class.php (前台搜索功能)
*
* @package YOURPHP
* @author liuxun QQ:147613338 <admin@yourphp.cn>
* @copyright Copyright (c) 2008-2011 (http://www.yourphp.cn)
* @license http://www.yourphp.cn/license.txt
* @version YourPHP企业网站管理系统 v2.1 2011-03-01 yourphp.cn $
*/
if(!defined("Yourphp")) exit("Access Denied");
class SearchAction extends BaseAction
{ function _initialize()
{
parent::_initialize();
} public function index()
{
//搜索
$_REQUEST['id'] = $catid = intval($_REQUEST['id']);
$p= max(intval($_REQUEST[C('VAR_PAGE')]),);
$_REQUEST['keyword'] = $keyword = get_safe_replace($_REQUEST['keyword']);
$_REQUEST['module'] = $module = get_safe_replace($_REQUEST['module']);
$module = $module ? $module : 'Article' ;
$this->assign($_REQUEST);
$this->assign('bcid',);
$where = " status=1 "; if(APP_LANG){
$lang = LANG_NAME;
$langid= LANG_ID;
$where .=" and lang= $langid";
$this->assign('lang',$lang);
$this->assign('langid',$langid);
} if($catid){
$cat = $this->categorys[$catid];
$bcid = explode(",",$cat['arrparentid']);
$bcid = $bcid[];
if($bcid == '') $bcid=intval($catid);
if(empty($module))$module=$cat['module'];
unset($cat['id']);
$this->assign($cat);
$cat['id']=$catid;
$this->assign('catid',$catid);
$this->assign('bcid',$bcid); if($cat['child']){
$where .= " and catid in(".$cat['arrchildid'].")";
}else{
$where .= " and catid=".$catid;
}
}
$seo_title = $cat['title'] ? $cat['title'] : $cat['catname'];
$this->assign ('seo_title',$keyword.' '.$seo_title);
$this->assign ('seo_keywords',$keyword.$cat['keywords']);
$this->assign ('seo_description',$keyword.$cat['description']); if($keyword){ if(strstr($keyword,'or')){
$keydo = ' or ';
$keyword_arr= explode('or',$keyword);
}elseif(strstr($keyword,' ')){
$keydo = ' AND ';
$keyword_arr= explode(' ',$keyword);
} if(count($keyword_arr)>){
foreach($keyword_arr as $key =>$keywordz){
$keyword_arr[$key] = ' title like "%'.trim($keywordz).'%" ';
}
$where .= ' AND ('.implode($keydo,$keyword_arr).')';
}else{
$where .= ' AND title like "%'.$keyword.'%" ';
}
}
$this->dao= M($module);
$count = $this->dao->where($where)->count();
$this->assign('count',$count); if($count){
import ( "@.ORG.Page" );
$listRows = !empty($cat['pagesize']) ? $cat['pagesize'] : C('PAGE_LISTROWS');
$page = new Page ( $count, $listRows );
$_REQUEST['p'] = '{$page}';
$page->urlrule = URL('Home-Search/index',$_REQUEST);
$pages = $page->show();
$field = $this->module[$cat['moduleid']]['listfields'];
$field = $field ? $field : 'id,catid,userid,url,username,title,title_style,keywords,description,thumb,createtime,hits';
$list = $this->dao->field($field)->where($where)->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
$this->assign('pages',$pages);
$this->assign('list',$list);
} $this->display(); }
}
?>
yourphp搜索代码的更多相关文章
- 完善dedecms站内搜索代码,为搜索结果添加第*页
自那些平凡而伟大的程序猿开发了内容管理系统(cms),为了让看客们更快地找到自己感兴趣的内容,他们不断完善站内搜索代码,形成了一个小型的站内搜索引擎.可能有些网站模板设计师没考虑到seo的问题,很多站 ...
- 一分钟加入google站内搜索代码
一分钟加入google站内搜索代码| 一分钟加入google站内搜索代码|只有7行最精简.网上有很多 google 站内搜索代码,但是出于某些目的,很多都加入了多余的代码,从seo的角度来讲,是很不优 ...
- [转载]《Delphi 版 everything、光速搜索代码》 关于获取文件全路径 GetFullFileName 函数的优化
Delphi 版 everything.光速搜索代码>,文章中关于获取文件全路径的函数:GetFullFileName,有一个地方值得优化. 就是有多个文件,它们可能属于同一个目录. 譬如 Sy ...
- Html 小插件5 百度搜索代码2
网页添加百度搜索框代码大全 ★ 用法:在下面选择合适的样式,复制代码到网页中相应位置粘贴即可. ★ 样式一(200×30)代码: <iframe id="baiduframe" ...
- 自适应大邻域搜索代码系列之(1) - 使用ALNS代码框架求解TSP问题
前言 上次出了邻域搜索的各种概念科普,尤其是LNS和ALNS的具体过程更是描述得一清二楚.不知道你萌都懂了吗?小编相信大家早就get到啦.不过有个别不愿意透露姓名的热心网友表示上次没有代码,遂不过瘾啊 ...
- python kd树 搜索 代码
kd树就是一种对k维空间中的实例点进行存储以便对其进行快速检索的树形数据结构,可以运用在k近邻法中,实现快速k近邻搜索.构造kd树相当于不断地用垂直于坐标轴的超平面将k维空间切分,依次选择坐标轴对空间 ...
- [转载]Delphi 版 everything、光速搜索代码
近日没啥事情,研究了一下 everything.光速搜索原理.花了一个礼拜时间,终于搞定. 废话不多说,直接上代码: unit uMFTSearchFile; { dbyoung@sina.com 2 ...
- stream,做减法,优化搜索代码。
做一个搜索,三个输入条件,求这个条件的交集.起初我的思路是按照操作的流程,一步步的来做这三个筛选. let searchResults = []; //step1 根据id搜索,得到一个子集. if ...
- [php] 使用IDE的正则搜索代码
([^a-zA-Z_=$0-9/\[\>])('|"|,)?(\s*)store_banner(\s*)('|"|,)?([^a-zA-Z_=$0-9\/\(\]:]) 用在 ...
随机推荐
- iPad开发--美团界面的搭建(主要是对Popover的使用,以及监听)
一.主界面的搭建,效果图.设置self.navigationItem.leftBarButtonItems属性. 由于leftBarButtonItem是通过xib文件创建的,通过xib创建的控件默认 ...
- 使用maven镜像
maven 的安装目录下的 conf 文件夹下有个 settings.xml 文件,编辑该文件 在<mirrors>中插入: <mirror> <id>repo2& ...
- linux-查看系统是32位还是64位
可以用命令“getconf LONG_BIT”查看, 如果返回的结果是32则说明是32位,返回的结果是64则说明是64位. 此外还可以使用命令“uname -a”查看, 输出的结果中,如果有x86_6 ...
- cookie的写入与读出
cookie在jquery中有指定的cookie操作类 $.cookie('the_cookie'); // 读取 cookie $.cookie('the_cookie', 'the_value') ...
- iOS推送处理
iOS收到推送后,跳转到某一页面 字数1348 阅读1001 评论4 喜欢26 以前做过推送, 但只是那种最基本的广播推送(向所有安装appde设备通知), 列播组播这种对指定用户推送消息还没做过, ...
- c# 文件转换成base64
private static void ReadFromFile() { FileStream fsForRead = new FileStream("c9a78c8a-29b0-410d- ...
- linux远程登陆其他主机并执行命令的若干方式
一.命令行登陆 ssh后,一定后边加双引号 写命令,否则命令实在本地执行的,多条命令的话用双引号隔开, ssh user@remoteNode "cd /home ; ls" 二. ...
- linux中/和/root(~) 和 /home
winodws是森林型目录结构,它有很多根,如C.D.E.F等都是它的根目录,然后在其实创建子目录linux是树型目录结构,它只有一个根就是/目录,然后在/目录在有子目录如/root./home./e ...
- restController与Controller-待续
restController包含controller和responseBody, restController返回一个对象时,会自动转换成json格式的数据,如果要返回视图和对象的那只能用contro ...
- hdu5175 gcd 求约数
题意:求满足条件GCD(N,M) = N XOR M的M的个数 sol:和uva那题挺像的.若gcd(a,b)=a xor b=c,则b=a-c 暴力枚举N的所有约数K,令M=NxorK,再判断gcd ...