[SalesForce] How to create a Related List with Custom Data

Is it possible to create a related list with custom data? I've built a visual force page with a controller extension that contains an apex page block iterating over a List of custom objects built from the controller extension:

Page:

<apex:page standardController="Account" extensions="MyTestController">
    <apex:pageblock id="testList" title="Test List"  >
        <apex:pageBlockTable value="{!items}" var="i" rendered="{!NOT(ISNULL(items))}">
            <apex:column value="{!i.Id}"/>
            <apex:column value="{!i.Name}"/>
        </apex:pageBlockTable>
        <apex:outputLabel value="No records to display" rendered="{!(ISNULL(items))}" styleClass="noRowsHeader"></apex:outputLabel>
    </apex:pageblock>
</apex:page>

Controller:

public class MyTestController {
    private Account acct; 
    List<Item__c> items; 
    public MyTestController(ApexPages.StandardController controller) {
        this.acct= (Account)controller.getRecord();
    }

    public List<Item__c> getItems()
    {
         List<Item__c> items = [select id, name from Item__c where account_id = :acct.id];
         return items;
    }
}

The above renders when I use the 'Edit Layout' on the Account page, then add the VF Page to the detail, but I am unable to add it in the related list area. The rendered table in the detail area looks similar to the sections in the Related List section, but I'd really rather have the look and feel of an actual Related List instead of a pageBlockTable.

Best Answer

You cannot add visualforce page as a related list.Need to override full page

Example 1

<apex:page standardController="Account">
    <apex:pageBlock>
    You're looking at some related lists for {!account.name}:
    </apex:pageBlock>

    <apex:relatedList list="Opportunities" />

    <apex:relatedList list="Contacts">
        <apex:facet name="header">Titles can be overriden with facets</apex:facet>
    </apex:relatedList>

    <apex:relatedList list="Cases" title="Or you can keep the image, but change the text" />
</apex:page>

Example 2

<apex:page standardcontroller="Account"> 
    <apex:detail relatedList="false" />
    <c:someComponent ... />
    <apex:relatedList list="Contacts" />
    <apex:relatedList list="Cases" />
    <apex:relatedList list="Opportunities" /> 
</apex:page>

Please check this link Custom Related List and Visual Force Page?

Also please vote this idea Ability to build custom related list in Visualforce