Might I suggest that you change the way that layout is applied to the view output? Rather than splitting it into a top and bottom, you can use output buffering to capture the output of the view, then pass it to a layout-file, that prints the content in the right place.