Azure API 管理中的应用程序模板Application templates in Azure API Management

通过 Azure API 管理,用户能够使用一组用于配置内容的模板自定义开发人员门户页面的内容。Azure API Management provides you the ability to customize the content of developer portal pages using a set of templates that configure their content. 使用 DotLiquid 语法和所选编辑器(例如 DotLiquid for Designers),以及提供的一组本地化字符串资源字形资源页面控件,即可根据这些模板的使用需要非常灵活地配置页面内容。Using DotLiquid syntax and the editor of your choice, such as DotLiquid for Designers, and a provided set of localized String resources, Glyph resources, and Page controls, you have great flexibility to configure the content of the pages as you see fit using these templates.

本部分中的模板可用于自定义开发人员门户中的应用程序页面的内容。The templates in this section allow you to customize the content of the Application pages in the developer portal.

备注

示例默认模板包含在后续文档中,但是会因持续改进而有所更改。Sample default templates are included in the following documentation, but are subject to change due to continuous improvements. 通过导航到所需单个模板,可在开发人员门户中查看实时的默认模板。You can view the live default templates in the developer portal by navigating to the desired individual templates. 如需详细了解如何使用模板,请参阅如何使用模板自定义 API 管理开发人员门户For more information about working with templates, see How to customize the API Management developer portal using templates.

备注

此文档内容与旧开发人员门户有关。This documentation content is about the legacy developer portal. 请参阅以下文章,了解有关新开发人员门户的内容:Refer to the following articles for content about the new developer portal:

可用性Availability

重要

此功能在 API 管理的“高级”、“标准”、“基本”和“开发人员”层中可用。This feature is available in the Premium, Standard, Basic and Developer tiers of API Management.

应用程序列表Application list

应用程序列表模板可用于自定义开发人员门户中应用程序列表页的正文。The Application list template allows you to customize the body of the application list page in the developer portal.

应用程序列表页开发人员门户模板Application List Page Developer Portal Templates

默认模板Default template

<div class="row">  
    <div class="col-md-9">  
        <h2>{% localized "AppStrings|WebApplicationsHeader" %}</h2>  
    </div>  
</div>  
<div class="row">  
    <div class="col-md-12">  
    {% if applications.size > 0 %}  
        <ul class="list-unstyled">  
        {% for app in applications %}  
            <li>  
            {% if app.application.icon.url != "" %}  
                <aside>  
                    <a href="/applications/details/{{app.application.id}}"><img src="{{app.application.icon.url}}" alt="App Icon" /></a>  
                </aside>  
            {% endif %}  
                <h3><a href="/applications/details/{{app.application.id}}">{{app.application.title}}</a></h3>  
                {{app.application.description}}  
            </li>     
        {% endfor %}  
        </ul>  
        <paging-control></paging-control>  
    {% else %}  
    {% localized "CommonResources|NoItemsToDisplay" %}  
    {% endif %}  
    </div>  
</div>  

控制Controls

Product list 模板可使用以下页面控件The Product list template may use the following page controls.

数据模型Data model

propertiesProperty 类型Type 说明Description
Paging 分页实体。Paging entity. 应用程序集合的分页信息。The paging information for the applications collection.
Applications 应用程序实体的集合。Collection of Application entities. 对当前用户可见的应用程序。The applications visible to the current user.
CategoryName 字符串string 应用程序的类别。The category of application.

示例模板数据Sample template data

{  
    "Paging": {  
        "Page": 1,  
        "PageSize": 10,  
        "TotalItemCount": 1,  
        "ShowAll": false,  
        "PageCount": 1  
    },  
    "Applications": [  
        {  
            "Application": {  
                "Id": "5702b96fb16653124c8f9ba8",  
                "Title": "Contoso Calculator",  
                "Description": "A simple online calculator.",  
                "Url": null,  
                "Version": null,  
                "Requirements": "Free application with no requirements.",  
                "State": 2,  
                "RegistrationDate": "2016-04-04T18:59:00",  
                "CategoryId": 5,  
                "DeveloperId": "5702b5b0b16653124c8f9ba4",  
                "Attachments": [  
                    {  
                        "UniqueId": "a58af001-e6c3-45fd-8bc9-c60a1875c3f6",  
                        "Url": "https://apimgmtst65gdjvjrgdbfhr4.blob.core.chinacloudapi.cn/content/applications/a58af001-e6c3-45fd-8bc9-c60a1875c3f6.png",  
                        "Type": "Icon",  
                        "ContentType": "image/png"  
                    },  
                    {  
                        "UniqueId": "2b4fa5dd-00ff-4a8f-b1b7-51e715849ede",  
                        "Url": "https://apimgmtst65gdjvjrgdbfhr4.blob.core.chinacloudapi.cn/content/applications/2b4fa5dd-00ff-4a8f-b1b7-51e715849ede.png",  
                        "Type": "Screenshot",  
                        "ContentType": "image/png"  
                    }  
                ],  
                "Icon": {  
                    "UniqueId": "a58af001-e6c3-45fd-8bc9-c60a1875c3f6",  
                    "Url": "https://apimgmtst65gdjvjrgdbfhr4.blob.core.chinacloudapi.cn/content/applications/a58af001-e6c3-45fd-8bc9-c60a1875c3f6.png",  
                    "Type": "Icon",  
                    "ContentType": "image/png"  
                }  
            },  
            "CategoryName": "Finance"  
        }  
    ]  
}  

应用程序Application

应用程序模板可用于自定义开发人员门户中应用程序页的正文。The Application template allows you to customize the body of the application page in the developer portal.

应用程序页开发人员门户模板Application Page Developer Portal Templates

默认模板Default template

<h2>{{title}}</h2>  
{% if icon.url != "" %}  
<aside class="applications_aside">  
  <div class="image-placeholder">  
    <img src="{{icon.url}}" alt="Application Icon" />  
  </div>  
</aside>  
{% endif %}  
  
<article>  
  {% if url != "" %}  
    <a target="_blank" href="{{url}}">{{url}}</a>  
  {% endif %}  
  
  <p>{{description}}</p>  
  
  {% if requirements != null %}  
  <h3>{% localized "AppDetailsStrings|WebApplicationsRequirementsHeader" %}</h3>  
  <p>{{requirements}}</p>  
  {% endif %}  
  
  {% if attachments.size > 0 %}  
  <h3>{% localized "AppDetailsStrings|WebApplicationsScreenshotsHeader" %}</h3>  
    {% for screenshot in attachments %}  
      {% if screenshot.type != "Icon" %}  
      <a href="{{screenshot.url}}" data-lightbox="example-set">  
          <img src="/Developer/Applications/Thumbnail?url={{screenshot.url}}" alt='{% localized "AppDetailsStrings|WebApplicationsScreenshotAlt" %}' />  
      </a>  
      {% endif %}  
    {% endfor %}  
  {% endif %}  
</article>  
  

控制Controls

Application 模板不允许使用任何页面控件The Application template does not allow the use of any page controls.

数据模型Data model

应用程序实体。Application entity.

示例模板数据Sample template data

{  
    "Id": "5702b96fb16653124c8f9ba8",  
    "Title": "Contoso Calculator",  
    "Description": "A simple online calculator.",  
    "Url": null,  
    "Version": null,  
    "Requirements": "Free application with no requirements.",  
    "State": 2,  
    "RegistrationDate": "2016-04-04T18:59:00",  
    "CategoryId": 5,  
    "DeveloperId": "5702b5b0b16653124c8f9ba4",  
    "Attachments": [  
        {  
            "UniqueId": "a58af001-e6c3-45fd-8bc9-c60a1875c3f6",  
            "Url": "https://apimgmtst3aybshdqqcqrle4.blob.core.chinacloudapi.cn/content/applications/a58af001-e6c3-45fd-8bc9-c60a1875c3f6.png",  
            "Type": "Icon",  
            "ContentType": "image/png"  
        },  
        {  
            "UniqueId": "2b4fa5dd-00ff-4a8f-b1b7-51e715849ede",  
            "Url": "https://apimgmtst3aybshdqqcqrle4.blob.core.chinacloudapi.cn/content/applications/2b4fa5dd-00ff-4a8f-b1b7-51e715849ede.png",  
            "Type": "Screenshot",  
            "ContentType": "image/png"  
        }  
    ],  
    "Icon": {  
        "UniqueId": "a58af001-e6c3-45fd-8bc9-c60a1875c3f6",  
        "Url": "https://apimgmtst3aybshdqqcqrle4.blob.core.chinacloudapi.cn/content/applications/a58af001-e6c3-45fd-8bc9-c60a1875c3f6.png",  
        "Type": "Icon",  
        "ContentType": "image/png"  
    }  
}  

后续步骤Next steps

如需详细了解如何使用模板,请参阅如何使用模板自定义 API 管理开发人员门户For more information about working with templates, see How to customize the API Management developer portal using templates.