thincmf 分页无法搜索_查询文章列表,不分页

# sp_sql_posts()

```php

sp_sql_posts($tag,$where)

```

功能:

查询文章列表,不做分页

参数:

`$tag`:查询语句(见$tag规则)

`$where`:查询条件,(暂只支持数组),格式和thinkphp where方法一样;

返回:

array 文章列表

示例:

```php

$tag='cid:6;field:post_title,post_content;order:listorder asc';

$posts=sp_sql_posts($tag);

print_r($posts);

$smeta=json_decode($vo['smeta'],true); //smeta处理方法,将其转化为数组

?>

```

`$tag`规则:

cid 分类id;

field 需要取出的内容,默认取出所有信息;order排序方式,可根据任何取出的字段排序,默认为按发布时间排序。

```

field可选参数:

term_id 文章分类id

post_author 文章作者id,后台管理员,对应于表users里的ID;

post_keywords

post_date 文章发布日期 格式2014-01-01 00:00:00

post_content 文章内容

post_title 文章标题

post_excerpt 文章摘要

post_modified 文章更新日期 格式2014-01-01 00:00:00

smeta 文章扩展属性,以json格式保存,如属性thumb文章缩略图

user_nicename 管理员昵称

user_email 管理员邮箱

```

模板中用法:

```html

$posts=sp_sql_posts('cid:6;field:post_title,post_content;order:listorder asc');

/* 遍历数组 */

{$vo.term_id }

{$vo.post_author }

{$vo.post_keywords }

{$vo.post_date }

{$vo.post_content }

{$vo.post_title }

{$vo.post_excerpt }

{$vo.post_modified}

{$vo.user_nicename }

{$vo.user_email }

$smeta=json_decode($vo['smeta'],true);/* 把smeta转化成数组 */

```

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值