<?php // +---------------------------------------------------------------------- // | OneThink [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- // | Copyright (c) 2013 http://www.onethink.cn All rights reserved. // +---------------------------------------------------------------------- // | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn> // +---------------------------------------------------------------------- namespace HomeController; include '/opt/xunsearch/sdk/php/lib/XS.php'; /** * 前台首页控制器 * 主要获取首页聚合数据 */ class IndexController extends HomeController { //系统首页 public function index(){ $xs = new XS('demo'); // 这里是关键, XS这个类不在HomeController空间中,是在公共空间,所以加反斜杠就不会提示class xxx not found 错误了 $search = $xs->search; $search->setCharset('UTF-8'); $search->setLimit(6); $query = '倍儿爽'; $search->setQuery($query); $docs = $search->search(); $this->assign('docs',$docs); //dump($docs); $this->display(); } // add public function add(){ $xs = new XS('demo'); $index = $xs->index; $data = array( 'id' => 1, 'title' => 'test title', 'content' => 'test content' ); $doc = new XSDocument; $doc->setFields($data); $index->add($doc); } // update public function update(){ $xs = new XS('demo'); $index = $xs->index; $data = array( 'id'=>1, 'title'=>'OneThink1.0正式版发布' ); $doc = new XSDocument; $doc->setFields($data); $index->update($doc); } // delete public function delete(){ $xs = new XS('demo'); $index = $xs->index; // $index->del('1'); // $index->del(array('1','2','3')); // $index->del('test','title'); // $index->del(array('test','ceshi'), 'title'); } }
<extend name="Base/common"/> <block name="header"> <header class="jumbotron subhead" id="overview"> <div class="container"> <h2>源自相同起点,演绎不同精彩!</h2> <p class="lead"></p> </div> </header> </block> <block name="side"> <!-- 左侧 nav ================================================== --> <div class="span3 bs-docs-sidebar"> <ul class="nav nav-list bs-docs-sidenav"> {:W('Category/lists', array(1, true))} </ul> </div> </block> <block name="body"> <div class="span9"> <section id="contents"> <volist name="docs" id="vo"> <h3><a href="{:U('Article/detail?id='.$vo['id'])}">{$vo.title}</a></h3> <p>{$vo.content}</p> </volist> <!-- <article:list name="article" category="1" child="true"> <div class=""> <h3><a href="{:U('Article/detail?id='.$article['id'])}">{$article.title}</a></h3> </div> <div> <p class="lead">{$article.description}</p> </div> <div> <span><a href="{:U('Article/detail?id='.$article['id'])}">查看全文</a></span> <span class="pull-right"> <span class="author">{$article.uid|get_username}</span> <span>于 {$article.create_time|date='Y-m-d H:i',###}</span> 发表在 <span> <a href="{:U('Article/lists?category='.get_category_name($article['category_id']))}">{$article.category_id|get_category_title}</a></span> ( 阅读:{$article.view} ) </span> </div> <hr/> </article:list>--> </section> </div> </div> </block>