My favorite way to embed views in template files is with the views_embed_view() function.

It's really easy to use:

&lt;?php print views_embed_view('view-name', 'display-name','arguments'); ?&gt;



The 'display-name' argument corresponds to the type of display in your view, and the number of those types of there are multiple. So if in your view you created two blocks, you could call one or the other by using 'block-1' or 'block-2' in the 'display-name' argument. 
The third argument, 'arguments', is optional, and can be used to pass any contextual filter arguments your view depends on. 


Insert a Views Block into a node in Drupal 7
I am getting compile time error while trying to assign userId to opShare.UserOrGroupId field. I am not sure what is wrong in it -

    List&lt;OpportunityShare&gt; grantAccessUpsertLst = new List&lt;OpportunityShare&gt;(); 
    for(String userId : userIds){
            List&lt;UserRecordAccess&gt; userRecords = [SELECT RecordId, HasEditAccess FROM UserRecordAccess WHERE UserId =: userId AND RecordId =: oppId];
            if(userRecords.size() &gt; 0 &amp;&amp; !(userRecords.get(0).HasEditAccess)){
                OpportunityShare opShare = new OpportunityShare();
                opShare.UserOrGroupId = userId; // Error Line
                opShare.OpportunityAccessLevel = ACCESS_LEVEL_EDIT;
                opShare.OpportunityID = oppId;
                grantAccessUpsertLst.add(opShare);          
            }
    }
    if(grantAccessUpsertLst.size() &gt; 0)
        upsert grantAccessUpsertLst;


Thanks in advance
