PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Accessing Event Comments

When using the full event view, comments are not directly stored within an entry. Instead, each event contains a URL to its associated comment feed which must be manually requested.

Working with comments is fundamentally similar to working with events, with the only significant difference being that a different feed and event class should be used and that the additional meta-data for events such as where and when does not exist for comments. Specifically, the comment's author is stored in the author property, and the comment text is stored in the content property.

<?php
// Extract the comment URL from the first event in a user's feed list
$event $eventFeed[0];
$commentUrl $event->comments->feedLink->url;

// Retrieve the comment list for the event
try {
$commentFeed $service->getFeed($commentUrl);
} catch (
Zend_Gdata_App_Exception $e) {
    echo 
"Error: " $e->getMessage();
}

// Output each comment as an HTML list
echo "<ul>";
foreach (
$commentFeed as $comment) {
    echo 
"<li><em>Comment By: " $comment->author->name "</em><br/>" .
         
$comment->content "</li>";
}
echo 
"</ul>";

Zend Framework