I am trying to display related content on a custom object within a Visualforce page. I created a custom object and attached a content document to it. I tried doing it using just Visualforce with the <apex:relatedList list="contentDistribution"
> tag (as well as some other relatedList options). That does not work. I tried a custom controller extension like so:
public class GVFExtension{
public List<ContentDocumentLink> gvfcontent;
public global_views__c gvfrecord;
public GVFExtension(ApexPages.StandardController stdController){
this.gvfRecord=(Global_Views__c)stdController.getRecord();
}
public List<ContentDocumentLink> getGVFContent(){
gvfContent=[SELECT ContentDocumentId, ContentDocument.title
FROM ContentDocumentLink
WHERE LinkedEntityId=:gvfRecord.Id];
return gvfContent;
}
}
And then my VF page (at least the relevant part):
<apex:pageBlock title="Related Content">
<apex:PageblockTable value="{!GVFContent}" var="g">
<apex:column>
<apex:outputLink value="/{!g.id}" target="_blank">{!g.ContentDocumentTitle}</apex:outputLink>
</apex:column>
<apex:column value="{!g.ContentDocumentId}"/>
</apex:PageblockTable>
</apex:pageBlock>
The header for the page block appears, but no related content appears (although I confirm it does appear on standard page layouts). When I look at my debug log it says that the extension was invoked properly but that the relatedRecordId query is using tmpVar1. I'm not sure what I am missing here.
If I can do it using a related list tag, that would be preferable, but all my searching indicates this is not so. I am using API version 33.0.
EDIT: Aha! I found that I should be using ContentDocumentLink, according to new Spring '15 options. Details here. So I updated my code above. The problem is, I still am not getting anything appearing in the Related Content view. The title appears but there is nothing showing.