简体   繁体   中英

How to export umbraco content

I'm new and I use Umbraco and asp.net My problem is that I need to export a lot of files that are in content (Umbraco). I tried with EyeCatch XML Export, but doesn't work. I tried to create a new package so that I can import in a other Umbraco, but that is not what I need. I need the content file in a XML file and in XSL file. For example, I need all files that are under the homepage, with the own image, etc. Does anyone know if there is some free package, or does anyone know how to do it?

There is already an XML file containing all the contents of your website, at /app_data/umbraco.config (Its extension of .config is what throws you off the scent).

Internally Umbraco uses this XML file when rendering all content.

I would look at UmbracoAPIController's. They will allow you to easily expose any of your data type's property values as XML or JSON. It is essentially an extension of Microsoft's Web API and is very easy to create. All you do is create a POCO class to store your content in, whose name ends in "Controller". You then extend UmbracoApiController. For example:

using System.Web.Mvc;
using Umbraco.Core.Models;
using Umbraco.Web;
using Umbraco.Web.WebApi;

namespace MyNamespace
{
    public class MyDocTypePoco
    {
        public string Name { get; set; }
        public string ImageUrl { get; set; }
    }


    public class MyDocTypeController : UmbracoApiController
    {
        [UmbracoAuthorize, AcceptVerbs("GET, POST"), System.Web.Http.HttpGet]
        public MyDocTypePoco GetPage(int id)
        {
            IPublishedContent node = Umbraco.TypedContent(id); // get our CMS node

            var myPoco = new MyDocTypePoco // instantiate POCO and populate
            {
                Name = node.GetPropertyValue<string>(node.Name), //  property of IPublishedContent
                ImageUrl = node.GetPropertyValue<string>("imageUrl") // my document type's custom property's alias
            };
        }
    }
}

Of course this would assume your image file was stored in a property with an alias of "imageUrl".

Once you've compiled your code, you should be able to call your service using this URL.

http://localhost/umbraco/api/MyDocType/GetPage?id=1234

1234 is the ID of the content node, and replace localhost with your domain you are running your site under (and add the port, etc). Note that you can remove the "UmbracoAuthorize" statement to allow you to view you service without having to be authenticated and logged in to the backend of Umbraco. This should never be done on live sites unless you are sure the data exposed by your controller is harmless.

Have a look here for more reading. Welcome aboard the Umbraco train! It's great fun and we're going from strength to strength in terms of what we can achieve.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM