Hi,
So I have a successful ajax call and I’m using with the data the ajax return calls.
$("div#status").html(data);
However I need to figure out how to print the pagination.
// display pagination
<?php $this->widget(‘CLinkPager’, array(
'pages' => $pages,
)) ?>
My pagination is just not showing at all. I don’t know whats wrong. I’m returning the data (the view) as the return from the ajax call. Its doing it correctly, but no pagination is being shown.
In my controller:
$pages = new CPagination(Marker::model()->countBySql($sql, $params));
$pages->pageSize = 20;
$pages->applyLimit($criteria);
$sql .= " LIMIT $criteria->limit OFFSET $criteria->offset";
$venues = Marker::model()->findAllBySql($sql, $params);
if ($venues == NULL) {
echo 'No Result';
//$this->redirect('noresult');
} else {
// Iterate through the rows, adding XML nodes for each
foreach ($venues as $location) {
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name", $location->name);
$newnode->setAttribute("address", $location->address);
$newnode->setAttribute("lat", $location->lat);
$newnode->setAttribute("lng", $location->lng);
$newnode->setAttribute("distance", $location->distance);
}
$data = $dom->saveXML();
echo $data;
$this->renderPartial('locate', array('venues'=>$venues, 'pages'=>$pages));
My View:
<?php
$index = 0;
foreach ($venues as $bus) {
?>
<div class="snglLst">
<div class="floatLeft"><div class="floatBackground"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/no-preview.gif" alt="<?php echo $bus->name; ?>"></div><div><strong><?php echo round($bus->distance, 1); ?> miles away</strong></div></div>
<div class="fL">
<div style="float:left; width:200px;">
<div class="mainHead"><a href="<?php echo $bus->bizurl; ?>"><?php echo $bus->name; ?></a></div>
<div><?php echo $bus->address0; ?> ( <a id="mapit" href="#" onClick="mapIt('<?php echo $index; ?>');">Map it</a> )</div>
<div><?php echo $bus->address1; ?></div>
<div><?php echo $bus->address2; ?></div>
<div><?php echo $bus->address3; ?></div>
<div><strong>Phone :</strong> <?php echo $bus->display_phone; ?></div>
<div><strong>RSVP : </strong> <span class="green">YES</span> ( <a href="#">Change</a> )</div>
</div>
<div style="float:left">
<div class="mainHead"><a href="#"> </a></div>
<div>Reviews: <?php
$reviews = (empty($bus->num_reviews)) ? '(' . $bus->num_reviews . ') <a class="statlink" href="#">Be the first to review</a>' : '(' . $bus->num_reviews . ') Write a Review';
echo $reviews;
?></div>
<div>Rating: <?php
$rating = (empty($bus->rating)) ? 'Has not been rated yet' : $bus->rating;
echo $rating;
?></div>
<?php echo CHtml::link('Create Event', array("events/create/$bus->bizurl"), array('class'=>'statlink')); ?>
</div>
</div>
<div class="fR">
<div class="top">Events<br>
<span class="green"><?php echo $bus->num_events; ?></span></div>
<div class="btm"><a href="#"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/facebook.png" alt="" width="16" height="16" border="0"></a><a href="#"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/twitter.png" alt="" width="16" height="16" border="0"></a></div>
</div>
<div class="clear"></div>
</div>
<?php
$index++;
}
?>
<?php $this->widget('CLinkPager', array('pages' => $pages));?>