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.
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?
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.
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?
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.
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.
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
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.
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
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.
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
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/
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!
Ha ha, a valiant effort though :)
is working on a reply...