Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Can't add review section in page


Go to End


2181 Views

Avatar
Anujit

Community Member, 3 Posts

17 July 2013 at 9:12pm

URL: http://golf.kc316.com/listingpage/show/17

All I am doing is based on search results, showing the details of golf course. Its working. I want to show the reviews made against the golf course. I tried adding a ReviewSection function. But didn't work.

Have anyone any idea?

The details page is named 'ListingPage.php'. The code snippent for ListingPage.php and ListingPage.ss is as below.

<b>LisingPage.php</b>

class ListingPage extends Page {
}
class ListingPage_Controller extends Page_Controller {
static $allowed_actions = array(
'show'
);

public function getGolfCourse()
{
$Params = $this->getURLParams();

if(is_numeric($Params['ID']) && $DT_GolfCourseProfile = DataObject::get_by_id('DT_GolfCourseProfile', (int)$Params['ID']))
{
Session::set('gfid', $Params['ID']);
return $DT_GolfCourseProfile;
}
}
function show()
{
if($DT_GolfCourseProfile = $this->getGolfCourse())
{
$Data = array(
'DT_GolfCourseProfile' => $DT_GolfCourseProfile
);

return $this->Customise($Data);
}
else
{
return $this->httpError(404, 'Sorry that golf course could not be found');
}
}

/*
function ReviewSection($num=5)
{
if($_SESSION['gfid'] != null)
return DataObject::get("Review", "GolfCourseID = ".$_SESSION['gfid'], "CREATED DESC", null, $num);
else
return false;
}
*/
}

<b>ListingPage.ss</b>

<div id="layoutListingPage">
<div class="panel" id="container">
<% control DT_GolfCourseProfile %>            
<div class="listings show" id="canvas">
<div class="paid-listing" id="left-column">
<div class="hreview-aggregate panel" id="basic-info">
<div class="vcard item">
<LH1 class="fn org">
$GCName
</LH1>
<p class="phone"><strong>$GCContPhone</strong></p>
<p class=""><strong><b>Fax: </b>$Fax</strong></p>
<p class=""><strong><b>Email: </b>$Email</strong></p>
<p class="primary-location" style="">
<span class="listing-address">
<span class="street-address">$Street</span>,
<br/>
<span class="city-state">
<span class="locality">$State</span>,
<span class="region">$City</span>,
<span class="postal-code">$Zip1-$Zip2</span>
</span>
</span>

</p>
<p class="location-description truncated" style="">
Near $County
</p>
</div>

</div>
<div class="section" id="business-reviews">
<div class="panel header">
<LH2>Reviews &amp; Recommendations</LH2>

<% control ReviewSection %>
$Comments <br /><br />
<% end_control %>

<p class="section-action"><a href="review" class="track-write-review write-review-link no-tracks" rel="nofollow">Write a Review</a></p>
</div>
</div>
</div>
</div>
</div>
<% end_control %>
</div>
</div>