Forum
Customize Search Results for the Events App
Hi,
I'm adding a search for the Perch Events app. Results are coming in fine and it was easy to setup.
Had some questions regarding how much customization we can have on the search results at this point in time. I understand its a basic text search and wanted to explore what's possible.
- Can I customize how search title field <perch:search id="title" /> displays or add other event fields in search results. For example, is it possible to display eventTitle and eventDateTime wrapped in its own markup?
- I see <perch:search id="title" /> and <perch:search id="excerpt" />. Could we return other text fields or thumbnails used in a template or is it limited to eventTitle, eventDateTime, and, I think, eventDescHTML in the excerpt?
- Can I customize format of eventDateTime? so a date could display June 20, 2015 instead of 20 Jun 2015. It's an American thing.
- Can I filter search results to display past events as well as upcoming events?
- Does paging show up depending on # of results automatically and split depending on count number set. I don't see an option for paging on the search template docs
Here is code on search page to display results
<?php
$query = perch_get('q');
$opts = array(
'count'=>5,
'excerpt-chars'=>300,
'sort'=>'eventDateTime',
'sort-order'=>'ASC',
'apps' => array('PerchEvents'),
'template'=>'search-result-events.html',
);
perch_content_search($query, $opts);
?>
Here is what <perch:showall /> displays for a sample event when I search on the term 'water'.
ID Value
perch_page_path /events/search.php
url 442
title Women and Water in the Developing World - 18 Jun 2015
excerpt In developing countries, women traditionally collect the water needed for drinking, washing,{...}
key water
source PerchEvents
result_url 442
result_title Women and Water in the Developing World - 18 Jun 2015
result_excerpt In developing countries, women traditionally collect the water needed for drinking, washing,{...}
result_key water
result_source PerchEvents
search_key water
paging false
total 2
number_of_pages 1
total_pages 1
per_page 5
current_page 1
lower_bound 1
upper_bound 2
prev_url
next_url
prev_page_number
next_page_number
perch_item_first true
perch_item_zero_index 0
perch_item_index 1
perch_item_rev_index 2
perch_item_rev_zero_index 1
perch_item_odd
perch_item_count 2
perch_namespace perch:search
Here are my diagnotics
Diagnostics report
HEALTH CHECK
Perch Runway is up to date
PHP 5.4.39 version is okay, but a little out of date. Consider updating soon.
MySQL 5.5.42 is up to date
Image processing available
SUMMARY INFORMATION
Perch Runway: 2.8.8, PHP: 5.4.39, MySQL: mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (2.8.8), assets (2.8.8), categories (2.8.8), collection_4 (2.8.8), perch_events (1.9.2), collection_1 (2.8.8), collection_5 (2.8.8), perch_podcasts (1.1)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_events', 'perch_podcasts', ); ?>
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/scottgruber/git/ioes-site/perch
PERCH_CORE: /Users/scottgruber/git/ioes-site/perch/core
PERCH_RESFILEPATH: /Users/scottgruber/git/ioes-site/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 32M, Max POST 32M, Memory: 256M, Total max file upload: 32M
Resource folder writeable: Yes
HTTP_HOST: dev.environment.ucla.edu:8888
DOCUMENT_ROOT: /Users/scottgruber/git/ioes-site
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Yes, I think so, but I'm checking into it.
I think this is the same as the first question, isn't it? Or have I missed the point?
Yes, use the
format
attribute.I'll check.
It should be the same as everywhere - the
count
option.Yes, the second question was a rephrase of the first.