We are having issues with pagination after one or more filters are applied. The results are correct for the first page, but not for the rest. I have tried the code in this thread with no change in results: http://chronoengine.com/forum/index.php?f=12&t=20616&start=15&hilit=pagination%20problem&rb_v=viewtopic
WHERE SQL:
HEADER:
BODY:
FOOTER:
The template being used is from RocketTheme but appears to use the default Joomla pagination so I was hoping the above thread would work. I posted in the paid forums as well and would be happy to pay someone to fix this or if someone has any suggestions, I'll take whatever I can get in the way of help at this point. It would be a shame to have to redo all of this since the pagination is the only problem really but is obviously a pretty major one if it prevents access to the filter results or at least most of them.
WHERE SQL:
<?php
$search = JRequest::getString('search', '', 'post');
$search1 = JRequest::getString('search1', '', 'post');
$search2 = JRequest::getString('search2', '', 'post');
$search3 = JRequest::getString('manufacturer', '', 'post');
$search4 = JRequest::getString('model', '', 'post');
$price_low = JRequest::getString('low_price', '', 'post');
$price_high = JRequest::getString('high_price', '', 'post');
$plane_hours = JRequest::getString('hours', '', 'post');
echo " WHERE `manufacturer` LIKE '%$search3%' AND `model` LIKE '%$search4%' AND `model` NOT LIKE '$search4 %' AND `model` NOT LIKE '% $search4' AND `asking_price` >= '$price_low' AND `asking_price` <= '$price_high' AND `airframe_time` <= '$plane_hours' AND `avionics_title` LIKE '%$search1%' AND (`serial` LIKE '%$search2%' OR`reg_number` LIKE '%$search2%') ";
?>
HEADER:
<?php
JHTML::_('behavior.mootools');
?>
<?php $doc =& JFactory::getDocument();
$script = "
window.addEvent('domready', function() {
$('manufacturer').addEvent('change', function () {
var a = $('manufacturer').value;
if ( a != null && a != '' ) {
getModel(a);
} else {
$('ajax_getmodel').setHTML(\"<span id='ajax_getmodel' >Please select a model</span>\")
}
}) ;
});
function getModel(a){
var url = \"index.php?option=com_chronocontact&chronoformname=SelectModel&task=extra&format=raw\";
new Ajax(url, {
method: 'get',
onRequest: function(){
$('progress_getmodel').setStyle('visibility', 'visible');
},
onComplete: function(){
$('progress_getmodel').setStyle('visibility', 'hidden');
},
update: $('ajax_getmodel'),
data: 'sid='+a
}).request();
};
";
$doc->addScriptDeclaration($script);
?>
<?php
// get the number of records returned
$db =& JFactory::getDBO();
global $count;
$count = $db->loadResult();
// add style & script snippets
$style = $script = "";
$style .= "
table.cf_listing {
margin-bottom: 12px;
}
";
$script .= "
$('clear').addEvent('click', function() {
$('search').value = '';
});
";
$doc =& JFactory::getDocument();
if ( $script ) {
$script = "window.addEvent('domready', function() { $script });";
$doc->addScriptDeclaration($script);
}
if ( $style) {
$doc->addStyleDeclaration($style);
}
// get the previous filter string
$search = JRequest::getString('search', '', 'post');
$search1 = JRequest::getString('search1', '', 'post');
$search2 = JRequest::getString('search2', '', 'post');
$status = JRequest::getString('status', '', 'post');
$low_price = JRequest::getString('low_price', '', 'post');
$high_price = JRequest::getString('high_price', '', 'post');
$hours = JRequest::getString('hours', '', 'post');
$manufacturer = JRequest::getString('manufacturer', '', 'post');
$model = JRequest::getString('model', '', 'post');
?>
<!-- display the filter box and buttons -->
<table><tr><td width="33%">
<label class="cf_label" style="width: 150px;">For Sale: </label>
<select class="cf_inputbox" id="status" size="1" title="" name="status">
<option value="">All Planes</option>
<option value="No">Yes</option>
<option value="Yes">No</option>
</select>
</td><td></td><td>
<label class="cf_label" style="width: 150px;">Total Hours: </label>
<select class="cf_inputbox" id="hours" size="1" title="" name="hours">
<option value="999,999">no limit</option>
<option value="1,000">under 1,000</option>
<option value="3,600">under 3,600</option>
<option value="5,000">under 5,000</option>
<option value="40,000">under 40,000</option>
</select>
</td></tr>
<tr><td width="33%">
<?php
if ( !$mainframe->isSite() ) { return; }
$db =& JFactory::getDBO();
$query = "
SELECT DISTINCT `manufacturer`
FROM `airplanes` WHERE manufacturer_list='1' ORDER BY manufacturer ASC;
";
$db->setQuery($query);
$data = $db->loadObjectList();
?>
<label class="cf_label" style="width: 150px;">Manufacturer</label>
<select class="cf_inputbox" id="manufacturer" size="1" title="" name="manufacturer">
<?php
foreach($data as $d) {
echo "<option value='".$d->manufacturer."'>".$d->manufacturer."</option>";
}
?>
</select>
</td><td>
<label class="cf_label" style="width: 150px;">Low Price: </label>
<select class="cf_inputbox" id="low_price" size="1" title="" name="low_price">
<option value="$0">any</option>
<option value="$1,000,000">$1,000,000</option>
<option value="$1,500,000">$1,500,000</option>
<option value="$1,750,000">$1,750,000</option>
<option value="$2,000,000">$2,000,000</option>
</select>
</td><td>
Avionics: <input type='text' name='search1' id='search1' value='<?php echo $search1; ?>' />
</td></tr>
<tr><td width="33%">
<label class="cf_label" style="width: 150px;">Model</label>
<span id='ajax_getmodel' style='color:#444;'>Please choose a model</span>
<span id='progress_getmodel' style='visibility:hidden;' > Searching . . .</span>
<?php
$manufacturer_id =& JRequest::getString('model', '', 'get');
if ( $manufacturer_id ) {
$db =& JFactory::getDBO();
$query = "
SELECT DISTINCT `model` AS `id`, `model`
FROM `airplanes`
WHERE `model` = '$manufacturer_id'
ORDER BY `model`;
";
$db->setQuery($query);
$data = $db->loadObjectList();
if ( count($data) ) {
$m = new stdClass();
$m->id = 0;
$m->model = '==?==';
$data = array_merge(array($m), $data);
$return = JHTML::_('select.genericlist', $data, 'model',
'class="inputbox required select" size="1" id="model_select" name="model_select" ', 'id', 'model', 0);
} else {
$return = "Sorry, we couldn't find that manufacturer";
}
} else {
$return = "";;
}
echo $return;
?>
</td><td>
<label class="cf_label" style="width: 150px;">Max Price: </label>
<select class="cf_inputbox" id="high_price" size="1" title="" name="high_price">
<option value="$999,999,999">no limit</option>
<option value="$1,000,000">$1,000,000</option>
<option value="$1,500,000">$1,500,000</option>
<option value="$1,750,000">$1,750,000</option>
<option value="$2,000,000">$2,000,000</option>
</select>
</td><td>
Model/Serial#: <input type='text' name='search2' id='search2' value='<?php echo $search2; ?>' />
</td></tr><tr><td clospan="3">
<input
type='submit' name='filter' id='filter' value='Filter' /> <INPUT type="button" value="Clear" onClick="location.href='index.php?option=com_chronoconnectivity&Itemid=17'"> <INPUT type="button" value="Add New Plane" onClick="location.href='index.php?option=com_chronocontact&Itemid=16'">
</td></tr></table>
<br>
<table class='cf_listing' width='800px'>
<?php
// check if there are any records returned
if ( !$count ) {
// no records - show the message
echo "<div>Sorry, no results were found.</div>";
} else {
// some records, show the header & footer rows
?>
<thead>
<tr><td><b>ID</b></td><td><b>Serial #</b></td><td><b>Year</b></td><td><b>Manufacturer</b></td><td><b>Model</b></td><td><b>Updated</b></td><td><b>View</b></td><td><b>Manage</b></td></tr>
</thead>
<tfoot>
<tr>
<td colspan='2' style='height:4px; background:silver;'></td>
</tr>
</tfoot>
<?php
}
?>
<tbody>
BODY:
<tr><td>{id} </td><td>{serial} </td><td>{year} </td><td>{manufacturer} </td><td>{model} </td><td>{last_update} </td><td><a href="index.php?option=com_chronocontact&chronoformname=EmailListing&id={id}">View</a></td><td>{edit_record}</td></tr>
FOOTER:
</tbody>
</table>
<?php
// get the row count and show the pagination if needed
global $count;
if ( $count ) {
?>
<?php
$script = "
window.addEvent('domready', function() {
var pagelinks = $$('div.page-inactive a');
var form = $$('form[name=connectivity]')[0];
var limitstart = $$('input[name=limitstart]')[0];
pagelinks.each(function(link) {
var href = link.getProperty('href');
var start = href.substr(href.lastIndexOf('start=')+6);
var title = link.getProperty('title');
var new_link = new Element('a', {
'events': {
'click': function() {
limitstart.value = new_link.getProperty('start');
form.submit();
}
},
'title': title,
'start': start
});
new_link.setText(title);
link.replaceWith(new_link);
});
});
";
$doc =& JFactory::getDocument();
$doc->addScriptDeclaration($script);
?>
{pagination}
<?php
}
?>
The template being used is from RocketTheme but appears to use the default Joomla pagination so I was hoping the above thread would work. I posted in the paid forums as well and would be happy to pay someone to fix this or if someone has any suggestions, I'll take whatever I can get in the way of help at this point. It would be a shame to have to redo all of this since the pagination is the only problem really but is obviously a pretty major one if it prevents access to the filter results or at least most of them.