Upgrading Template 3.0.0 to 3.0.1

This guide also applies for the tag template.

Simple Review 3.0.1 has a new feature for category templates which allows you to use placeholders when creating your review listing template. This change will allow you to easily add custom fields to your review listing without having to resort to using PHP. You can ignore this guide if you are using an unmodified category template that comes with Simple Review e.g. default or dark. If you have created your own template or modified the existing category review listing template (template.reviewlisting.html.php) the below will show you the difference and what to change.

Old template code to replace (~line 109-124):

<?php
$isAlt = false;
foreach($reviews as $r):
$css = $isAlt ? 'odd' : 'even';
$isAlt = !$isAlt;
$reviewName = Simple_Review_Common::RemoveSlashes($r->name);
$reviewName = "<a href='$r->url'>$reviewName</a>";
?>
<tr class="<?php echo $css;?>">
<td><?php echo $reviewName;?></td>
<td><?php echo $r->rating;?></td>
<td><?php echo $r->averageUserRating;?></td>
<td><?php echo $r->createdByName;?></td>
<td><?php echo $r->createdDate;?></td>
</tr>
<?php endforeach;?>

New template code:

<?php
$isAlt = false;
foreach($reviews as $r):
$css = $isAlt ? 'odd' : 'even';
$isAlt = !$isAlt;
ob_start();
?>
<tr class="<?php echo $css;?>">
<td><a href='{Review:Url}'>{Review:Title}</a></td>
<td>{Review:Rating}</td>
<td>{Review:RatingUser}</td>
<td>{Review:Author}</td>
<td>{Review:Date}</td>
</tr>
<?php
$tableRow = ob_get_contents();
ob_end_clean();
echo $this->Replace($r, $tableRow);
endforeach;?>

As you can see the table row’s cells (<td>) no longer contain any PHP.

2 thoughts on “Upgrading Template 3.0.0 to 3.0.1”

Comments are closed.