Copied to clipboard

Flag this post as spam?

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


  • Charles Roper 48 posts 200 karma points
    Mar 21, 2016 @ 20:29
    Charles Roper
    0

    Populate property fields based on a querystring

    I want to be able to pre-populate some content fields by including a querystring in the backoffice URL which is used to go and scrape some data to populate the fields.

    E.g., say I've make the following request:

    http://mydomain/umbraco/#/content/content/edit/1136?doctype=myPage&create=true&scrape=http://www.example.com

    Given this, we would scrape www.example.com and get back some data (using Angular?) to fill some fields which can then be edited in the normal way.

    To give an example, imagine a "report this page" button on an intranet that only shows up for people with appropriate permissions. When the user clicks it, they get taken to the above URL with the scrape querystring populated with the page they just came from. The form they are presented with will contain the page title, description and URL of the page they reported, gathered by scraping.

    Is this possible? Is there an alternative approach that might be better?

    Many thanks in advance.

    Charles

  • Aristotelis Pitaridis 84 posts 402 karma points
    Mar 22, 2016 @ 05:06
    Aristotelis Pitaridis
    100

    This can not be done automatically but if you want to do it I can think two different ways to implement it.

    The first way to do it is to create a content programmatically and set the values for the fields that you want and then redirect the user to the equivalent url (http://mydomain/umbraco/#/content/content/edit/1136) in order to type the remainder properties.

    The second way is to create a custom backoffice extension which will get the values as you defined in the sample url and create a content with the specified values. Again I think it would be nice to redirect the user to the default edit content page in order to let the user type the other properties which will not be set automatically.

  • Charles Roper 48 posts 200 karma points
    Mar 22, 2016 @ 08:37
    Charles Roper
    0

    Thanks Aristotelis, that gives me at least two good routes to explore. Have you got any tutorial recommendations for learning how to create a backoffice extension?

    Thanks again!

    Charles

  • Aristotelis Pitaridis 84 posts 402 karma points
    Mar 22, 2016 @ 09:22
    Aristotelis Pitaridis
    0

    If you do not know how to make an extension then it would be better to create the content programmatically and redirect to the backoffice with the content ID that you created in order to continue the content editing.

  • Charles Roper 48 posts 200 karma points
    Mar 22, 2016 @ 09:48
    Charles Roper
    0

    Yes, that is what I'll probably end up doing, thanks.

    I should clarify that I am only doing these things as a side project to help learn Umbraco more deeply, hence the interest in backoffice extensions. I've not tried creating content programmatically either, but I've been learning about SurfaceControllers and how to add content, so that's what I'll probably do.

    Thanks again.

    Charles

  • Charles Roper 48 posts 200 karma points
    Mar 22, 2016 @ 09:54
    Charles Roper
    0

    In case anyone else comes across this thread, here's a decent looking series of posts on how to build a backoffice extension:

    http://blogit.create.pt/andresantos/2015/11/16/building-an-umbraco-7-backoffice-extension-part-i/

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Mar 22, 2016 @ 20:38
    Marc Goodson
    0

    Hi Charles

    Yes I was trying to reply to a thread with broken html! by hacking the reply box in chrome :-)

    didn't work then!

  • Charles Roper 48 posts 200 karma points
    Mar 22, 2016 @ 20:39
    Charles Roper
    0

    Ha ha, a valiant effort though :)

Please Sign in or register to post replies

Write your reply to:

Draft