Functions:pageForumPostsGet

From Whirlwind eCommerce Wiki
Revision as of 14:10, 21 October 2008 by Root (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Page Template Managers

Page Template Functions

Description

Retrieves array of forum post data

Syntax

$postArray = eV::pageForumPostsGet([$userId][,$pageId,][$templateIdList,][$fieldList,][$orderBy]);

Paramaters

  • $userId INT OPTIONAL (either userId OR pageId MUST be passed)
Entering a value into this field will filter all forum posts by this user. Use this field to get all forum posts on all pages by a specific user.
  • $pageId INT OPTIONAL (either userId or pageId MUST be passed)
Entering a value into this field will filter all forum posts by this page. Use this field to show all forum posts made to a particular page.
  • $templateIdList STRING OPTIONAL
comma delimited list of templateIds to filter post results by. This is used in conjunction with userId to show only posts made by the user to pages that belong to certain templates (I.e. show only posts to products via product templates)

Return Values

Returns an associative array of aggregate post data. The 'posts' root element contains an indexed array of all individual posts qualifying for this request. Each indexed element is an associative array of post data. The returned array is as follows:

Array
(
    ['ratingAverage'] => FLOAT
    ['ratingTotal'] => INT
    ['ratingCount'] => INT
    ['ratingCount1'] => INT
    ['ratingCount2'] => INT
    ['ratingCount3'] => INT
    ['ratingCount4'] => INT
    ['ratingCount5'] => INT
    ['posts'] => Array
        (
           [0] => Array
                (
                   [post_createDate] => DATETIME
                   [post_modDate] => DATETIME
                   [post_userId] => INT
                   [post_handle] => STRING
                   [post_postHandle] => STRING
                   [post_userHandle] => STRING
                   [post_emailAddress] => STRING
                   [post_postEmailAddress] => STRING
                   [post_userEmailAddress] => STRING
                   [post_firstName] => STRING
                   [post_lastName] => STRING
                   [post_userImage] => STRING
                   [post_copy] => STRING
                   [page_title] => STRING

                   [reply_copy] => STRING
                   [reply_handle] => STRING
                   [reply_emailAddress] => STRING
                   [reply_firstName] => STRING
                   [reply_lastName] => STRING
                   [reply_userEmailAddress] => STRING
                   [reply_userHandle] => STRING
                   [reply_postHandle] => STRING
                   [reply_userImage] => STRING
                   [reply_postId] => INT
                   [reply_userId] => INT
                   [reply_title] => STRING
                   [reply_createDate] => DATETIME
                   [reply_modDate] => DATETIME
                   [reply_postEmailAddress] => STRING
                   [reply_postHandle] => STRING

                   [isEditable] => BIT
                   [deleteLink] => STRING
                   [editLink] => STRING
                   [replyLink] => STRING
                   [anchor] => STRING

                   [agreeTotal] => INT
                   [agreeCount] => INT
                )
           [1] => Array ...
        )

)

Elements from the root associative array are as follows. Note only elements specifically request in fieldList will be returned, unless fieldList is empty than all will be returned:

Element Description Example
ratingAverage FLOAT - average rating posted for all posts qualifying for this request. On a scale of 0 - 5. 3.4
ratingTotal INT - aggrigate sum of all the ratings for all posts qualifying for this request 192
ratingCount INT - count of all ratings posted for all posts qulifying for this request. ratingTotal / ratingCount = ratingAverage 75
ratingCount1 INT - total number of ratings submitted with a rating of 1 14
ratingCount2 INT - total number of ratings submitted with a rating of 2 22
ratingCount3 INT - total number of ratings submitted with a rating of 3 42
ratingCount4 INT - total number of ratings submitted with a rating of 4 19
ratingCount5 INT - total number of ratings submitted with a rating of 5 8
posts Array - indexed array of all posts qualifying for this request. [Array]

Elements from each post in the posts array. Note only elements specifically request in fieldList will be returned, unless fieldList is empty than all will be returned:

Element Description Example
post_createDate DATETIME
post_modDate DATETIME
post_userId INT
post_handle STRING
post_postHandle STRING
post_userHandle STRING
post_emailAddress STRING
post_postEmailAddress STRING
post_userEmailAddress STRING
post_firstName STRING
post_lastName STRING
post_userImage STRING
post_copy STRING
page_title STRING
reply_copy STRING
reply_handle STRING
reply_emailAddress STRING
reply_firstName STRING
reply_lastName STRING
reply_userEmailAddress STRING
reply_userHandle STRING
reply_postHandle STRING
reply_userImage STRING
reply_postId INT
reply_userId INT
reply_title STRING
reply_createDate DATETIME
reply_modDate DATETIME
reply_postEmailAddress STRING
reply_postHandle STRING
isEditable BIT
deleteLink STRING
editLink STRING
replyLink STRING
anchor STRING
agreeTotal INT
agreeCount INT

Examples

Simple Example
// only process forum requests and output if forums is available and selected for this page
// accessing global settings variable forums_available and page core variable $isForum
if($GLOBALS['iProducts']['forums_available'] AND $isForum){
   // get postings for current page
   // using core variable $page to get forum data for the current page we are in
   $forumArray = eV::pageForumPostsGet(NULL,$pageId,NULL,"post_createDate,post_handle,post_copy,post_title");
 
   // shortcut to the post array
   $postsArr = $forumArray['posts'];
 
   if(count($postsArr) > 0){
      // loop thru posts
      foreach($postsArr as $post){
         echo "<hr>" . $post['post_title'] . " by " . $post['post_handle'] . " on " . $post['post_createDate'];
         echo "<br>" . $post['post_copy'];
      };
   } else {
      // no posts to this forum, lets output this to visitors
      echo "no posts to this forum";
   };
 
   // 123 below represents the pageId for the forum post page
   echo "<hr><a href=\"index.php?pageId=123\">Click here to post to this forum!</a><hr>";
// end if foroums available and this is a forum
};