Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • John French 32 posts 83 karma points
    Nov 23, 2016 @ 00:58
    John French
    0

    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

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Nov 23, 2016 @ 22:43
    Marc Goodson
    100

    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

Please Sign in or register to post replies

Write your reply to:

Draft