First of All, Thanks to PW Team for bringing us such a great CMS.
I downloaded copy early this year but started work on it yesterday. I created few template files for search and results but one of the custom field is not displaying any result. Text field name is "roll_no", which contains only numbers and this is the code for search template. Student name and Father name fields are showing results.
<?php
/**
* Search template
*
*/
$out = '';
if($q = $sanitizer->selectorValue($input->get->q)) {
$input->whitelist('q', $q);
$matches = $pages->find("title|roll_no|student_name|father_name~=$q, limit=50");
$count = count($matches);
if($count) {
$out .= "<h2>Found $count results matching your query:</h2>" .
"<table class='result'><tr><th>Student Name</th><th>Father Name</th><th>Class</th><th>Roll No</th><th>Result</th><th>Total Marks</th></tr>";
foreach($matches as $m) {
$out .= "<tr><td><a href='{$m->url}'>{$m->title}</a></td><td>{$m->father_name}</td><td>{$m->class}</td><td>{$m->roll_no}</td><td>{$m->result}</td><td>{$m->numbers}</td></tr>";
}
$out .= "</table>";
} else {
$out .= "<h2>Sorry, no results were found.</h2>";
}
} else {
$out .= "<h2>Please enter a search term in the search box (upper right corner)</h2>";
}
include("./head.inc");
echo $out;
include("./foot.inc");
My another question is about Search input field.. I setup a custom select field with Fieldtype: Select module. Feild name is "class" with 4 options (7th, 8th, 9th, 10th).. I also want to display these select options beside search input field. So user enter student name or roll no and then choose class for results.
This is code for exam page template with search input field.
<?php include("./head.inc"); ?>
<form id='search_form' action='<?php echo $config->urls->root?>result-search/' method='get' class="search-form">
<input type='text' name='q' id='search_query' value='<?php echo htmlentities($input->whitelist('q'), ENT_QUOTES, 'UTF-8'); ?>' class="search-text-box" />
<input type='submit' id='search_submit' class="search-submit-button" />
</form>
<?php include("./foot.inc"); ?>
Any help would be really appriciated.