问题标签 [glass-mapper]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
6292 浏览

asp.net-mvc-4 - Mvc 4 中的 Sitecore glass mapper 通用链接

嗨,我目前正在使用 MVC4 和 glassmapper 学习 sitecore 7,但我在一般链接字段方面遇到了一些问题。我似乎无法从一般链接字段中正确输出外部链接(不是指向项目的链接)。我究竟做错了什么?

我的模型:

在视图中:

输出:

提前致谢。

0 投票
1 回答
2453 浏览

c# - How to solve could not load assembly using Sitecore7 and Glassmapper

For a project I'm using Sitecore version 7 and the latest version of GlassMapper. It's an ASP.net MVC3 project. When I try to add a new controller, an error occured:

Microsoft Visual Studio

Could not load file or assembly 'Sitecore.Kernel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

Can GlassMapper work with Sitecore version 7.0? Does anyone know how to solve this problem? I don't like it if I need to downgrade to Sitecore version 6.6.

Thanks a lot.

Jordy

0 投票
3 回答
10648 浏览

c# - 使用 Glass Mapper for Sitecore 获取内部链接的绝对 URL

我的项目模板有一个字段 aGeneral Link并由以下类表示:

现在我的链接字段包含外部和内部链接(指向其他项目的链接)。是否可以配置 Glass Mapper 的Url属性Link包含绝对 url(如AlwaysIncludeServerUrl=true)?并且还使用了站点解析(SiteResolving=true)?

基本上我想给 Link 属性一个UrlOptions配置。

我正在Sitecore 7.1使用Glass.Mapper.Sc 3.1.2.18.

0 投票
0 回答
1448 浏览

asp.net-mvc-4 - 在 Sitecore MVC 中保存表单帖子会生成“未找到方法”错误

有没有其他人遇到过这样的错误?如果有人可以提出一种进一步检查的方法或者可能有解决方案的方向,那就太好了。

我试图调试这个但无法弄清楚。cshtml 文件中指定的操作已达到,发布的信息可用。执行此行时发生错误。

确实WikiEntryModel包含一个. ImageField调用表单时不填写,也不指定为表单中的字段。

附加信息

我将 GlassMapper v2.0 与 Sitecore 7.1 结合使用。

这是页面上显示的实际错误描述。

找不到方法:'System.String Sitecore.Data.Fields.ImageField.get_MediaPath()'。

表单的 cshtml 文件。

控制器中指定动作的代码。

0 投票
2 回答
2882 浏览

sitecore - Editable Sitecore text field within a Sitecore Glass link field renderer

Using standard sitecore controls (Link and Text), you can embed a text field within a link in the following way:

That will give you the ability to edit the text of one field and link of another field.

I have tried to replicate this using Glass, but have been unsuccessful. Something like this would be good (It doesn't work):

Is there another way of sorting this out?

There are two options I see if I cannot do this using standard glass functionality:

  1. Change the GlassHtml code
  2. Use Two Fields
0 投票
1 回答
1978 浏览

c# - 我可以在 SitecoreQuery 属性中使用相对快速的查询吗?

我有一个正在工作的 Sitecore 7 + Glass Mapper 3 安装,我希望对其进行优化。

我的代码的一个例子是:

我希望使用 FastQuery,但出现错误:

字符串结尾应在位置 4

尝试了以下解决方案,这涉及插入getLookupSourceItems管道 - 但我认为这不是正确的管道,因为它不会在调试中触发。

Glass 在这种情况下是否使用了另一条管道(如果有的话)?有没有其他方法可以解决我加快速度的目标?

如果我不使用属性而是扩展方法,我可以手动执行此操作并用于*[@@id='']设置根节点,但我希望尽可能避免这种情况。

0 投票
1 回答
1064 浏览

c# - 在 Sitecore 玻璃映射器中禁用特定属性的版本检查

我正在SItecore 7.1使用Glass.Mapper.Sc 3.1.7.26. 我有以下模型,其中Service Id字段是共享的:

我有以下模型,它在一个Droptree字段上引用服务映射(也共享):

当我加载它的实例时,OnlineService它必须依赖于语言,因为DisplayName. 假设我有OnlineService德语和英语版本,而我ServiceMapping只有英语版本,然后在请求德语页面时获取对象nullServiceMapping

是否可以为ServiceMapping.ServiceId属性提供一个不应该检查现有语言版本的设置?我知道有VersionCountDisabler(),但我不能使用它,因为我需要OnlineService类来检查语言版本。

0 投票
2 回答
1630 浏览

sitecore - 页面编辑器中的 Sitecore Glass Mapper ObjectToSwitchTo 空引用

我在visual studio中具有以下结构作为模板:

在一个页面下,我有一个或多个链接根

在链接根下我有 LinkItems

我在这样的视图中显示这些项目:

效果很好,我可以看到带有好名字的链接等,但是当我转到页面编辑器时,我收到了这个错误:

值不能为空。参数名称:objectToSwitchTo

在 Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName) 在 Sitecore.Common.Switcher 2.Enter(TValue objectToSwitchTo) at Sitecore.Data.Items.ContextItemSwitcher..ctor(Item item) at Glass.Mapper.Sc.GlassHtml.MakeEditable[T](Expression1 字段,Expression`1 标准输出,T 模型,对象参数,上下文上下文,数据库数据库,TextWriter 编写器)

是否有人已经经历过或知道我为什么会出现此错误?

谢谢

0 投票
1 回答
550 浏览

sitecore - 在 Glass.Mapper 中使用值继承

我在实际项目中使用 Glass.Mapper,需要实现值继承。

例如,我有元关键字,我想将其映射到 Glass.Mapper 模型中。如果该字段为空,我想在该字段中找到最近的父项,并在我当前的模型中使用该值。

该字段是一个Single-Line Text命名的Meta Keywords.

因为当前项目没有字段值,所以我想做一个递归检查并Keyword1, Keyword2Home Item我当前的 Glass.Mapper 模型中获取值。

最好的方法是什么?我知道那里有一个 Field Fallback 模块,它可以执行此类操作并将值动态设置为当前项目的标准值。Glass.Mapper 是否提供了一些功能以更简单的方式执行此操作?

0 投票
1 回答
1704 浏览

c# - Sitecore Glass Mapper property from multiple fields

I´m using Sitecore and Glass Mapper, and I´d like to know if the following is possible:

I have a Sitecore Item, which has 5 fields. These fields are CSS classes (height, width, effects, icons, etc). It´s a metro style webpage, so the idea is to allow the user to change some settings on the fly.

Instead of making 5 different properties, and access each field, I´d like to know if there is a way to return those 5 fields as a list, or a string.

That would be my Model for each setting. And this is my Tile:

And I´d like to access those in the property CSSCLasses, instead of going one by one like this, for example: