Preheat the oven to 350 degrees F (175 degrees C). Grease and flour two 8-inch or 9-inch round cake pans.
In a large bowl, whisk together the flour, baking powder, baking soda, and salt. Set aside.
In a separate large bowl, cream together the butter and granulated sugar until light and fluffy.
Beat in the eggs one at a time, mixing well after each addition.
Stir in the crushed pineapple (with the juice) and vanilla extract.
Alternate between adding the dry ingredients and 1 cup of the milk to the wet ingredients, beginning and ending with the dry ingredients. Blend until just combined – don't overmix!
Divide the batter between your prepared pans.
Bake for 25-30 minutes, or until a toothpick inserted into the center comes out clean.
Let the cakes cool in the pans for 15-20 minutes before inverting onto a wire rack to cool completely.
Make the coconut pastry cream:
In a medium saucepan, whisk together 2 1/2 cups of the milk, the sweetened condensed milk, egg yolks, flour, cornstarch, and salt.
Heat over medium heat, stirring constantly, until the mixture thickens and comes to a boil.
Reduce heat to low and simmer for 1 minute.
Remove from the heat. Stir in the shredded coconut and vanilla extract.
Let the coconut pastry cream cool slightly.
Make the pineapple jelly:
In a small saucepan, whisk the pineapple juice, sugar, and the gelatin powder.
Bring to a simmer over medium heat and cook for 1 minute, stirring until gelatin has dissolved.
Remove from the heat and let it cool to room temperature.
Assemble and frost the cake:
Level the tops of the cakes if needed for a flat stacking surface.
Place one cake layer on a serving plate. Spread with a layer of coconut pastry cream and then a layer of the cooled pineapple jelly.
Place the second cake layer on top.
Whip the heavy cream and powdered sugar to stiff peaks.
Gently fold the drained crushed pineapple and shredded coconut into the whipped cream.
Spread the coconut-pineapple foam over the top and sides of the cake.
Chill the cake for at least 1 hour before serving.
Notes
Use fresh pineapple or top-quality canned pineapple for the best flavor in the cake and jelly.
You can toast the shredded coconut before adding it to the pastry cream and topping for an extra flavor boost.
If you don't have crushed pineapple on hand, you can puree a can of pineapple chunks.