简体   繁体   English

使用 Masterpages 在 Umbraco 网页上显示 XML 内容(用于站点地图)

[英]Showing XML content on on an Umbraco webpage with Masterpages (for sitemap)

I am running a multisite instance of Umbraco.我正在运行 Umbraco 的多站点实例。 Everything is going well, but now I need to create a sitemap.一切都很顺利,但现在我需要创建一个站点地图。

I have managed to create the Macro that displays a perfect XML formatted sitemap, but....我设法创建了显示完美 XML 格式站点地图的宏,但是....

I can't figure out how to to display on the page with the proper headers.我不知道如何使用正确的标题在页面上显示。 Right now it looks like this:现在它看起来像这样:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title></title>
</head>
<body>
   <form method="post" action="./sitemap" id="form1">
     <div class="aspNetHidden">
         <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="faEtomis/pJrnOEH1FjMt3tYgJgnPP8lddqb60IlljFoqaMzmdGrfFsw4WeF9tCiqAa6bpN0obMQKnBNa1OmWHYSPuVgJB8116lnS+3eY95EqMoOpeTPa8jbsUSJXzXx" />
     </div>
     <div>
       <url>
          <loc>https://www.example.com/</loc>;
          <lastmod>2017-02-12T17:41:48+00:00</lastmod>
       </url>
     </div>
     <div class="aspNetHidden">
        <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="CA0B0334" />
     </div>
</form>
</body>
</html>

Obviously, this is not a properly formatted XML sitemap file.显然,这不是一个格式正确的 XML 站点地图文件。

My problem is that the umbraco/default.master has to have the base html, head, body tags to allow the ContentPlaceHolder for my template to work.我的问题是 umbraco/default.master 必须有基本的 html、head、body 标签,以允许我的模板的 ContentPlaceHolder 工作。

What can I do to make this work?我能做些什么来完成这项工作?

Your Sitemap.Master template (or whatever you're using to place the sitemap xml structure on) doesn't have to inherit from anything but the default Umbraco MasterPage, which shouldn't contain any HTML markup whatsoever.您的 Sitemap.Master 模板(或您用来放置站点地图 xml 结构的任何模板)不必继承自默认的 Umbraco MasterPage 之外的任何内容,该模板不应包含任何 HTML 标记。 For example, a stock standard install of Umbraco has the following /Umbraco/MasterPages/Default.Master:例如,Umbraco 的标准安装具有以下 /Umbraco/MasterPages/Default.Master:

<%@ Master Language="C#" AutoEventWireup="True" CodeBehind="Default.master.cs" Inherits="Umbraco.Web.UI.Umbraco.Masterpages.Default" %>
<asp:ContentPlaceHolder ID="ContentPlaceHolderDefault" runat="server">
</asp:ContentPlaceHolder>

It's worth noting that if you are indeed using Umbraco 7 (or 6 for that matter), you could create a Template using MVC instead of MasterPages and it would still work.值得注意的是,如果您确实在使用 Umbraco 7(或 6),您可以使用 MVC 而不是 MasterPages 创建一个模板,它仍然可以工作。

For a more detailed answer, share your current Sitemap Masterpage template and structure...如需更详细的答案,请分享您当前的站点地图主页模板和结构...

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

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