简体   繁体   English

如何导出umbraco内容

[英]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). 我是新手,使用Umbraco和asp.net我的问题是我需要导出很多内容文件(Umbraco)。 I tried with EyeCatch XML Export, but doesn't work. 我尝试了EyeCatch XML Export,但没有用。 I tried to create a new package so that I can import in a other Umbraco, but that is not what I need. 我试图创建一个新程序包,以便可以导入其他Umbraco,但这不是我所需要的。 I need the content file in a XML file and in XSL file. 我需要XML文件和XSL文件中的内容文件。 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). /app_data/umbraco.config中已经有一个包含您网站所有内容的XML文件(.config的扩展名是使您远离气味的原因)。

Internally Umbraco uses this XML file when rendering all content. 在呈现所有内容时,Umbraco在内部使用此XML文件。

I would look at UmbracoAPIController's. 我会看一下UmbracoAPIController。 They will allow you to easily expose any of your data type's property values as XML or JSON. 它们将使您轻松地将任何数据类型的属性值公开为XML或JSON。 It is essentially an extension of Microsoft's Web API and is very easy to create. 它实质上是Microsoft Web API的扩展,非常易于创建。 All you do is create a POCO class to store your content in, whose name ends in "Controller". 您要做的就是创建一个POCO类来存储您的内容,其名称以“ Controller”结尾。 You then extend UmbracoApiController. 然后,您扩展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". 当然,这将假定您的图像文件存储在别名为“ imageUrl”的属性中。

Once you've compiled your code, you should be able to call your service using this URL. 编译代码后,您应该可以使用此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). 1234是内容节点的ID,将localhost替换为您要在其下运行站点的域(并添加端口等)。 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. 请注意,您可以删除“ UmbracoAuthorize”语句,以无需查看身份验证和登录到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! 欢迎乘坐Umbraco火车! It's great fun and we're going from strength to strength in terms of what we can achieve. 这非常有趣,我们在实现目标方面正不断前进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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