简体   繁体   English

从特定的Chatter组将帖子(海报名称,照片,正文)获取到VF页面-努力进入VF

[英]Getting posts (poster name, photo, text body) into VF page from specific Chatter group - Struggling getting into VF

I am working off of some code I found on the Internet - I have only been on the ADM 201 course. 我正在处理一些在Internet上找到的代码-我只上过ADM 201课程。

What I am doing is attempting to pull the information from a post and then put this into a VF page. 我正在做的是尝试从帖子中提取信息,然后将其放入VF页面。 I know I can use chatter:feed, but this is getting all of the information and functions, whereas I need only the text body, poster name, and picture (not essential). 我知道我可以使用chatter:feed,但这可以获取所有信息和功能,而我只需要文本正文,海报名称和图片(不是必需的)。

What I have so far: 到目前为止,我有:

Apex Class: 顶点类:

    public class Test_3 {        //Class is 
public ConnectApi.FeedElementPage feedElementPage{get;set;}
public Test_3() {
    feedElementPage =    ConnectApi.ChatterFeeds.getFeedElementsFromFeed('0F958000000TWvL',   ConnectApi.FeedType.Record, 'showInternalOnly');
    }
    }

VF page: VF页面:

<apex:page controller="Test_5">
   <div class="posts">
      <div class="row">
      <div class="col-md-6">
        <apex:repeat value="{!feed.elements}" var="feedElement">
            <div class="media">
                <a class="pull-left" href="{!feedElement.parent.id}">
                <img class="media-object" src="{!feedElement.photoUrl}" alt="{!feedElement.actor.name}"/>
                    </a>
                    <div class="media-body">
                        <h4 class="media-heading">{!feedItem.actor.name}</h4>
                        // This creates a heading from the posts that is the poster's name
                        {!feedElement.body.text}
                        // This is the body of the post
                        </div>
                    </div>
       </apex:repeat>
      </div>
 </div>
</div>

 <footer>
    <p>&copy; Operations Updates - Please refresh your browser for the latest</p>
 </footer>
</apex:page>

Current issues: 当前的问题:

  • !feedElement.parent.id !feedElement.parent.id
  • !feedItem.actor.name !feedItem.actor.name
  • "Error: Unknown property 'ConnectApi.Feed.elements'" “错误:未知属性'ConnectApi.Feed.elements'”

Anyway, I can't work this out. 无论如何,我无法解决。 I've been trying to make this for a lovely 5 hours now. 我一直在努力使它变得可爱5个小时。

Any help would be much appreciated. 任何帮助将非常感激。

The code was modified from here and then I attempted to update it to Elements from Items. 这里修改了代码,然后我尝试将其更新为Items中的Elements。

Thanks 谢谢

In your Apex class, the variable is called "feedElementPage" but in the Visualforce page, it says "feed". 在Apex类中,变量称为“ feedElementPage”,但在Visualforce页面中,变量为“ feed”。 Please update feedElementPage to feed in Apex class or update repeat value="{!feed.elements}" to repeat value="{!feedElementPage.elements}" 请更新feedElementPagefeed中的Apex类或更新repeat value="{!feed.elements}"repeat value="{!feedElementPage.elements}"

In addition, I think you should use FeedItem instead of FeedElement . 另外,我认为您应该使用FeedItem而不是FeedElement Please take a look at the document, and let me know if you have any other questions. 请查看该文档,如果还有其他问题,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM