在页面< head>中添加元素在Orchard CMS中 [英] Adding an element to page <head> in Orchard CMS

查看:51
本文介绍了在页面< head>中添加元素在Orchard CMS中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向我最近从同事那里继承的Orchard网站添加新页面.该页面的目的是为我们的Google Chrome扩展程序提供内联安装.

I am adding a new page to an Orchard site that I recently inherited from a co-worker. The page's purpose is to provide inline installation for our Google Chrome extension.

要支持此功能,需要在页面的head元素中添加一个指向Google网上商店页面的链接,例如

Supporting this functionality requires adding a link in the page's head element to the Google webstore page e.g.

<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/apdfllckaahabafndbhieahigkjlhalf">

如何在页面头部添加元素?我知道我们有一些执行类似操作的Orchard模块,这是否需要一个模块?

How can I add an element to a page's head? I know we have some Orchard modules that do similar things, does this require a module?

推荐答案

我不知道任何能够在头部添加任意链接标签的模块,因此您有两个选择:

I don't know of any module capable of adding arbitrary link tags to the head, so you have two options:

  1. 通过注册形状模板中的链接从主题中添加它;这意味着您需要在主题中有一个模板,用于构建网站布局.为此,您可以在您的主题中覆盖现有模板(例如Document.cshtml),然后在其中添加注册.有一个漂亮基础主题开发人员主题专门用于帮助在这种情况下,可以使用扩展点,这样您就不必完全覆盖(并且首先复制粘贴)现有形状即可包含您自己的形状.
  2. 通过ResourceManager从模块添加它.
  1. Add it from a theme by registering the link from a shape template; this means you need to have a template in your theme that is used when building the layout of the site. For this you could e.g. override an existing template, like Document.cshtml from your theme and add the registration there. There is the Pretty Good Base Theme developer theme specifically designed to aid such scenarios by having extension points so you don't have to completely override (and does first copy-paste) an existing shape to include your own.
  2. Add it from a module through the ResourceManager.

广告1:

RegisterLink(new Orchard.UI.Resources.LinkEntry
{
    Rel = "chrome-webstore-item",
    Href = "https://chrome.google.com/webstore/detail/apdfllckaahabafndbhieahigkjlhalf"
});

广告2:在您的代码中注入一个IResourceManager(应该在需要此链接条目的每个请求上运行;可能是IResultFilter),并以与上一点相同的方式使用它.

Ad 2: Inject an IResourceManager in your code (that should run on every request where this link entry is needed; so maybe an IResultFilter) and use it in the same way as in the previous point.

这篇关于在页面&lt; head&gt;中添加元素在Orchard CMS中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆