I would like to pull in different Views in my default layout.
‘default.ctp’ is my main layout template and this is currently only pulling in content from ‘view/posts/index.ctp’, however, I’d also like to include my add news form (‘view/posts/add.ctp’) in this template.
Is this easy to achieve?
I looked at the manual about ‘elements’ but it didn’t seem to help.
Thank you for any pointers.
If you want to render on a page for one action result of another action, Object::requestAction() can halp you.
In place in view (view/posts/index.ctp), where you want to display other view (view/posts/add.ctp), put this cpode:
More about requestAction
In case if you want only render other templete – View::render() for you.
This method render a templete only without execution action and don’t work correct in same situations (eg. where used paginator).
Code:
‘/Posts/add’ – for CakePHP 2, for 1.3 – ‘/posts/add’