我试图Field.HasValue
在Razor语法中使用Sitecore的属性来测试特定的字段,但无论我尝试什么,该字段似乎总是错误的.
这是我正在尝试的:
@{
var phoneNumber = "";
var numberField = Model.Item.Fields["Header Number"];
if (numberField != null && numberField.HasValue)
{
phoneNumber = numberField.Value;
}
}
Run Code Online (Sandbox Code Playgroud)
正如您在下面的屏幕截图中看到的:
numberField
正确设置为Sitecore字段numberField.HasValue
报道 false
numberField.Value
(正确地)返回字段的值if
块,phoneNumber
因此永远不会设置:这是一个错误吗?我使用HasValue
不正确或是否有另一个Sitecore方法我应该用来安全地测试字段是否有值?
我试图将CSS类添加到Sitecore 8中的Rich Text编辑器中。我在web.config中包括了对CSS文件的引用,如下所示
<settings>
<setting name="WebStylesheet">
<patch:attribute name="value">/Stylesheets/Corporate/rte.css</patch:attribute>
</setting>
</settings>
Run Code Online (Sandbox Code Playgroud)
我的CSS类如下所示:
.utility.background-color-dark-blue:focus, .utility.background-color-dark-blue:hover {
background-color: #034b76;
color: #fff;
}
.utility.background-color-dark-grey {
background-color: #1a1b1f;
color: #fff;
}
Run Code Online (Sandbox Code Playgroud)
当我从RTE的下拉列表中选择CSS类时,它仅将“ background-color-dark-grey”类应用于该元素。我需要将CSS类应用为“ utility background-color-dark-grey”,以显示正确的样式。
有谁知道如何在sitecore中向RTE添加多个类?
我想为WFFM表单字段类型添加其他属性.
我想将自己的部分和属性添加到此区域.这可以轻松完成而不会覆盖现有的字段类型或使用核心代码进行黑客攻击吗?
我真的不想重新创建例如单行文本字段,只是为了添加我自己的属性字段.
在页面编辑器中保存页面时出现错误.不知何故,当我从演示文稿>详细信息编辑页面并在页面编辑器中显示它时工作正常..错误日志在下面这里..
ERROR After parsing a value an unexpected character was encountered: {. Path 'scLayout', line 38, position 85. Exception: Newtonsoft.Json.JsonReaderException
Message: After parsing a value an unexpected character was encountered: {. Path 'scLayout', line 38, position 85. Source: Newtonsoft.Json
at Newtonsoft.Json.JsonTextReader.ParsePostValue()
at Newtonsoft.Json.JsonTextReader.ReadInternal()
at Newtonsoft.Json.JsonTextReader.Read()
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, …
Run Code Online (Sandbox Code Playgroud) 我正在处理多站点,我想打开上下文站点的体验编辑器,但 sitecore 无法解析上下文站点,它总是将我带到默认网站,sitecore.config 文件中有一个设置,我将其设置为“ true”,但它仍然带我到默认网站:
http://mywebsite.local/?sc_mode=edit&sc_site=网站
这是sitecore.config中的设置,我的sitecore版本是8.1(更新2)
<!-- PREVIEW - RESOLVE SITE
If false, the Preview.DefaultSite setting specifies the context site to use when a user previews an item.
If true, when a user previews an item, Sitecore tries to resolve the root item and the context site based on the current content language
and the path to the item. If Sitecore cannot resolve the context site, it uses the site that is specified in the Preview.DefaultSite setting.
Default value: …
Run Code Online (Sandbox Code Playgroud) 我需要从外部服务验证用户凭据,因此我正在使用VirtualUser
身份验证.
BuildVirtualUser
,检查要设置给他的角色,保存用户配置文件,然后使用该名称登录.我遇到了一个问题,即每天登录,使用相同的凭据,Sitecore会在体验资料中创建一个新用户.
我需要在代码中更改以确保通过虚拟用户登录,Sitecore获取用户的旧体验配置文件?
我正在考虑使用相同的通用密码在sitecore中创建用户.而不是使用虚拟用户,并直接与sitecore进行身份验证.那是对的吗?
这是我的代码:
Sitecore.Security.Accounts.User user = Sitecore.Security.Authentication.AuthenticationManager.BuildVirtualUser(sitecoreUser, true);
string roleName = @"newRole\User";
Sitecore.Security.Accounts.Role demoRole = Sitecore.Security.Accounts.Role.FromName(roleName);
if (Sitecore.Security.Accounts.Role.Exists(roleName) && !demoRole.IsMember(user, true, false))
{
user.Roles.Add(Sitecore.Security.Accounts.Role.FromName(roleName));
}
user.Profile.Name = name;
user.Profile.Email = email;
user.Profile.FullName = fullname;
user.Profile.Save();
Sitecore.Security.Authentication.AuthenticationManager.Login(user.Name);
Tracker.Initialize();
Run Code Online (Sandbox Code Playgroud) 我们正在使用 Sitecore 8.1,并希望向“开始”菜单添加一个新应用:
怎么能这样呢?
我如何检查已安装在 Sitecore 8 中的 WFFM 版本。我正在检查数据/包文件夹中的包列表。这是正确的方法吗?
我想知道 Sitecore 8.2 中的任何内置个性化规则是否符合我所寻找的要求。使用个性化,我试图使页面上的模块在您第一次访问该页面时显示。当前会话中对该页面的任何后续访问都不会呈现该模块。
我认为内置规则“当前访问期间已访问[特定页面] ”会起作用,但在我的场景中不起作用。如果[特定页面]参数不是当前页面,它会起作用,但这不是我需要的。
似乎访问是在验证规则之前记录的,因此当规则最终验证时,它认为该页面之前已经被访问过,而实际上这可能是第一次页面访问。
除了创建自定义规则之外还有什么想法吗?提前致谢。
我正在安装 Sitecore 8.2 解决方案并设置环境。我使用的是 TDS Hedgehog 5.8.0.6。我遇到了一个我的同事都没有遇到过的奇怪错误:当我尝试将内容项目与 Sitecore 同步时(通过上下文单击内容项目中的菜单项“与 Sitecore 同步项目”),我在 Visual Studio 2019 中收到一个弹出窗口仅包含标题栏、关闭、展开和停靠按钮以及空框架。无论我将其打开多久,窗口中都不会显示任何内容。
我已重新启动计算机、重新启动 Visual Studio、重新安装 TDS 扩展、已构建项目(我们对解决方案和要构建的特定项目有特定的顺序),并通过“属性”窗口的“构建”选项卡测试了 TDS 连接的项目。所有项目都这样做。我确实安装了 Sitecore 8.2 和 Visual Studio Professional 2019 的 TDS。输出窗口中没有日志,错误窗口中没有错误或警告。
有其他人在 Visual Studio 中看到过这个吗?有人有解决办法吗?
编辑:如果这有帮助的话,我在 ActivityLog.Setup.xml 中发现了一些警告。
<entry>
<record>42</record>
<time>2019/10/10 00:17:05.020</time>
<type>Warning</type>
<source>VisualStudio</source>
<description>PkgDef encountered data collision in section 'HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\16.0_bc996d64_Config_15432\ToolsOptionsPages\TDS Options' for value ''</description>
</entry>
<entry>
<record>43</record>
<time>2019/10/10 00:17:05.021</time>
<type>Warning</type>
<source>VisualStudio</source>
<description>PkgDef encountered data collision in section 'HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\16.0_bc996d64_Config_15432\ToolsOptionsPages\TDS Options' for value 'Package'</description>
</entry>
<entry>
<record>44</record>
<time>2019/10/10 00:17:05.022</time>
<type>Warning</type>
<source>VisualStudio</source> …
Run Code Online (Sandbox Code Playgroud) sitecore ×10
sitecore8 ×10
c# ×3
sitecore-mvc ×3
json ×1
razor ×1
rte ×1
sitecore8.1 ×1
tds ×1
version ×1