I have a website with lots of profile nodes and I want to create an "edit" page for each profile. e.g /profile/john/edit. But I don't want to create an edit page node under each profile node as they are thousands so I want to use route hijacking or make use of IContentFinder so when someones types in /profile/john/edit it displays the edit profile form with the profile details of "john" already populated. ..Any ideas how I can do this?
Umbraco has a little known feature called 'alternative templates' that you could use here.
Basically you can load any page with a different template to the one it is published on by adding to the querystring
?altTemplate=myalternativetemplatename
so you could create a template called 'edit', containing a form to edit the details for the person's profile and load it via
/profile/john?altTemplate=edit
but that's not the url you want...
... that's ok because by convention if you have the url
/profile/john/edit
then this will do exactly the same thing,... look for a template called 'edit' and use this for the John page.
So on your alternative edit template, you can create a form that posts back to a surface controller action, that takes the posted values, validates, adn uses the contentservice to update the profile, and then return the user to the current umbraco page, which will then display the profile in the published template with the updated data...
Route Hijacking for edit page
Hi,
I have a website with lots of profile nodes and I want to create an "edit" page for each profile. e.g /profile/john/edit. But I don't want to create an edit page node under each profile node as they are thousands so I want to use route hijacking or make use of IContentFinder so when someones types in /profile/john/edit it displays the edit profile form with the profile details of "john" already populated. ..Any ideas how I can do this?
Thanks
Hi James
Umbraco has a little known feature called 'alternative templates' that you could use here.
Basically you can load any page with a different template to the one it is published on by adding to the querystring
?altTemplate=myalternativetemplatename
so you could create a template called 'edit', containing a form to edit the details for the person's profile and load it via
/profile/john?altTemplate=edit
but that's not the url you want...
... that's ok because by convention if you have the url
/profile/john/edit
then this will do exactly the same thing,... look for a template called 'edit' and use this for the John page.
So on your alternative edit template, you can create a form that posts back to a surface controller action, that takes the posted values, validates, adn uses the contentservice to update the profile, and then return the user to the current umbraco page, which will then display the profile in the published template with the updated data...
regards
Marc
is working on a reply...