Difference between revisions of "Functions:pageForumPostsGet"

From Whirlwind eCommerce Wiki
Jump to: navigation, search
(New page: == Description == Retrieves array of forum post data == Syntax == $postArray = eV::pageForumPostsGet([$userId][,$pageId,][$templateIdList,][$fieldList,][$orderBy]); == Paramaters == *$us...)
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{Page Template Functions Shortcuts}}
 
== Description ==
 
== Description ==
 
Retrieves array of forum post data
 
Retrieves array of forum post data
Line 14: Line 15:
  
 
== Return Values ==
 
== Return Values ==
Return multi dimensional array where first dimension is the index associated with the specific post, the second dimension is an associative array of data for that post.  
+
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.  
Return array is as follows:
+
The returned array is as follows:
  
 
<pre>
 
<pre>
 
Array
 
Array
 
(
 
(
 +
    ['ratingAverage'] => FLOAT
 +
    ['ratingTotal'] => INT
 +
    ['ratingCount'] => INT
 +
    ['ratingCount1'] => INT
 +
    ['ratingCount2'] => INT
 +
    ['ratingCount3'] => INT
 +
    ['ratingCount4'] => INT
 +
    ['ratingCount5'] => INT
 
     ['posts'] => Array
 
     ['posts'] => Array
 
         (
 
         (
 
           [0] => Array
 
           [0] => Array
 
                 (
 
                 (
                   [] => Array
+
                   [post_createDate] => DATETIME
post_createDate
+
                  [post_modDate] => DATETIME
post_modDate
+
                  [post_userId] => INT
post_userId
+
                  [post_handle] => STRING
post_handle
+
                  [post_postHandle] => STRING
post_postHandle
+
                  [post_userHandle] => STRING
post_userHandle
+
                  [post_emailAddress] => STRING
post_emailAddress
+
                  [post_postEmailAddress] => STRING
post_postEmailAddress
+
                  [post_userEmailAddress] => STRING
post_userEmailAddress
+
                  [post_firstName] => STRING
post_firstName
+
                  [post_lastName] => STRING
post_lastName
+
                  [post_userImage] => STRING
post_emailAddress
+
                  [post_copy] => STRING
post_userImage
+
                  [page_title] => STRING
post_copy
+
  
page_title
+
                  [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
  
reply_copy
+
                  [isEditable] => BIT
reply_handle
+
                  [deleteLink] => STRING
reply_emailAddress
+
                  [editLink] => STRING
reply_firstName
+
                  [replyLink] => STRING
reply_lastName
+
                  [anchor] => STRING
reply_userEmailAddress
+
reply_userHandle
+
reply_postHandle
+
reply_userImage
+
reply_postId
+
reply_userId
+
reply_title
+
reply_createDate
+
reply_modDate
+
reply_postEmailAddress
+
reply_postHandle
+
  
ratingAverage
+
                  [agreeTotal] => INT
ratingTotal
+
                  [agreeCount] => INT
ratingCount
+
                )
ratingCount1
+
          [1] => Array ...
ratingCount2
+
ratingCount3
+
ratingCount4
+
ratingCount5
+
 
+
agreeTotal
+
agreeCount
+
 
         )
 
         )
    [1] ...
+
 
 
)
 
)
 
</pre>
 
</pre>
 +
 +
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:
 +
{|border=2
 +
|-
 +
|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:
 +
{|border=2
 +
|-
 +
|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 ==
 
== Examples ==
Line 79: Line 284:
 
<source lang="php">
 
<source lang="php">
  
// get postings for current page
+
// only process forum requests and output if forums is available and selected for this page
$postArr = eV::pageForumPostsGet(NULL,$pageId,NULL,'
+
// 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
 +
};
 +
 
 
</source>
 
</source>

Latest revision as of 14:10, 21 October 2008

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
};