本文整理汇总了PHP中Post::search方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::search方法的具体用法?PHP Post::search怎么用?PHP Post::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::search方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: results
public function results()
{
$keywords = Input::get('words');
$this->data['words'] = strip_tags($keywords);
$this->data['results'] = Post::search($keywords);
if (count($this->data['results']) === 1) {
return Illuminate\Support\Facades\Redirect::to(WebAPL\Language::url('topost/' . $this->data['results'][0]->id));
}
WebAPL\Template::setPageTitle("Search: {$this->data['words']}", true);
PageController::loadGeneralResources();
$this->layout->content = View::make('sections.search.results', $this->data);
}
示例2: search
function search($terms)
{
$posts = Post::search($terms)->get();
return View::make('pages.frontpage', ['posts' => $posts]);
}
示例3: function
* Search
*/
Route::get(array('search', 'search/(:any)', 'search/(:any)/(:num)'), function ($slug = '', $offset = 1) {
// mock search page
$page = new Page();
$page->id = 0;
$page->title = 'Search';
$page->slug = 'search';
// get search term
$term = filter_var($slug, FILTER_SANITIZE_STRING);
Session::put(slug($term), $term);
//$term = Session::get($slug); //this was for POST only searches
// revert double-dashes back to spaces
$term = str_replace('--', ' ', $term);
if ($offset > 0) {
list($total, $posts) = Post::search($term, $offset, Config::meta('posts_per_page'));
} else {
return Response::create(new Template('404'), 404);
}
// search templating vars
Registry::set('page', $page);
Registry::set('page_offset', $offset);
Registry::set('search_term', $term);
Registry::set('search_results', new Items($posts));
Registry::set('total_posts', $total);
return new Template('search');
});
Route::post('search', function () {
// search and save search ID
$term = filter_var(Input::get('term', ''), FILTER_SANITIZE_STRING);
// replace spaces with double-dash to pass through url
示例4: Meme
<?php
require_once '../lib/YahooMeme.class.php';
$meme = new Meme();
print "<h2>[info about bigo]</h2> <br />";
print $meme->get("bigodines")->toString(true);
print "<h2>[people following bigodines]</h2> <br/>";
$repo = new MemeRepository();
foreach ($repo->following("bigodines") as $row) {
print $row->toString() . "<br />";
}
print "<h2>[bigo latest 5 posts]</h2>";
foreach ($meme->get("bigodines")->getPosts(0, 5) as $row) {
print $row->toString() . "<br />\n";
}
print "<h2>[meme popular posts]</h2> <br />";
$post = new Post();
foreach ($post->popular() as $row) {
print $row->toString() . "<br />";
}
print "<h2>[latest 5 posts from meme]</h2> <br />";
foreach ($post->search('sort:cdate', 0, 5) as $row) {
print $row->toString() . "<br />\n";
}
示例5: function
* Search
*/
Route::get(array('search', 'search/(:any)', 'search/(:any)/(:num)'), function ($slug = '', $offset = 1) {
// mock search page
$page = new Page();
$page->id = 0;
$page->title = 'Search';
$page->slug = 'search';
// get search term
$term = filter_var($slug, FILTER_SANITIZE_STRING);
Session::put(slug($term), $term);
//$term = Session::get($slug); //this was for POST only searches
// revert double-dashes back to spaces
$term = str_replace('--', ' ', $term);
if ($offset > 0) {
list($total, $posts) = Post::search($term, $offset, Post::perPage());
} else {
return Response::create(new Template('404'), 404);
}
// search templating vars
Registry::set('page', $page);
Registry::set('page_offset', $offset);
Registry::set('search_term', $term);
Registry::set('search_results', new Items($posts));
Registry::set('total_posts', $total);
return new Template('search');
});
Route::post('search', function () {
// search and save search ID
$term = filter_var(Input::get('term', ''), FILTER_SANITIZE_STRING);
// replace spaces with double-dash to pass through url
示例6: Template
$page->id = 0;
$page->title = 'Search';
$page->slug = 'search';
if ($offset <= 0) {
return Response::create(new Template('404'), 404);
}
// Convert custom escaped characters and escape MySQL special characters.
// http://stackoverflow.com/questions/712580/list-of-special-characters-for-sql-like-clause
$term = str_replace(array('-sl-', '-bsl-', '-sp-', '%', '_'), array('/', '\\\\', ' ', '\\%', '\\_'), $slug);
// Posts, pages, or all
if ($whatSearching === 'posts') {
list($total, $results) = Post::search($term, $offset, Post::perPage());
} elseif ($whatSearching === 'pages') {
list($total, $results) = Page::search($term, $offset);
} else {
$postResults = Post::search($term, $offset, Post::perPage());
$pageResults = Page::search($term, $offset);
$total = $postResults[0] + $pageResults[0];
$results = array_merge($postResults[1], $pageResults[1]);
}
// search templating vars
$safeTerm = eq(str_replace(array('\\\\', '\\%', '\\_'), array('\\', '%', '_'), $term));
Registry::set('page', $page);
Registry::set('page_offset', $offset);
Registry::set('search_term', $safeTerm);
Registry::set('search_results', new Items($results));
Registry::set('total_posts', $total);
return new Template('search');
});
Route::post('search', function () {
// Search term, placeholders for / and \
示例7: actionJobs
public function actionJobs()
{
$model = new Post('search');
$model->unsetAttributes();
// clear any default values
if (isset($_GET['Post'])) {
$model->attributes = $_GET['Post'];
}
//send model object for search
$this->render('jobs', array('dataProvider' => $model->search(), 'model' => $model));
}
示例8: search
/**
* search
*
* @return Response
*/
public function search()
{
$query = Input::get('q');
$page = Input::get('page');
$posts = [];
if ($query) {
$posts = Post::search($query);
}
if (count($posts)) {
$url = sprintf('/search?q=%s&page=:page', rawurlencode($query));
$paginator = Paginator::get($posts, $page, $url);
} else {
$paginator = null;
}
$html = Layout::find('search')->render(['search' => true, 'query' => $query, 'paginator' => $paginator]);
return Response::make($html);
}
示例9: search
public function search($slug)
{
$posts = Post::search($slug);
REST::returnJson(['status' => 'search', 'posts' => $posts]);
}