Sitecore 8是否内置了对MVC区域的支持?或者我还需要安装sitecore插件吗?
谢谢
我是Sitecore的新手.我正在尝试实现以下流程类来覆盖GeoIP值以进行测试.
我找不到类跟踪器所在的命名空间.请注意,我使用的是localhost上托管的Sitecore 8.Sitecore博客:@sitecorejohn博客
有人可以帮我解决这个命名空间问题.
谢谢.
namespace Sitecore.Sharedsource.Analytics.Pipelines.StartTracking
{
using System.Net;
using Sitecore.Analytics;
using Sitecore.Analytics.Pipelines.StartTracking;
public class OverrideIPAddress
{
public void Process(StartTrackingArgs args)
{
if (Tracker.CurrentVisit == null
|| Tracker.CurrentVisit.GeoIp == null
|| Tracker.CurrentVisit.Ip == null)
{
return;
}
string ip = new IPAddress(
Tracker.CurrentVisit.GeoIp.Ip).ToString();
if (ip != "0.0.0.0" && ip != "127.0.0.1")
{
return;
}
string html = Sitecore.Web.WebUtil.ExecuteWebPage(
"http://www.whatismyip.com/automation/n09230945.asp");
IPAddress address = IPAddress.Parse(html);
Tracker.CurrentVisit.GeoIp =
Tracker.Visitor.DataContext.GetGeoIp(address.GetAddressBytes());
}
}
}
Run Code Online (Sandbox Code Playgroud) 是否可以将现有的子布局(ascx)添加到分页器中的sitecore mvc占位符?如果我添加它,没有任何反应,但根本没有错误.
在我看来,以下工作是什么:
@{ Html.RenderPartial("Dummy.ascx");}
Run Code Online (Sandbox Code Playgroud)
Sitecore将渲染该子布局,但如果ascx文件嵌套了另一个子布局,则不会渲染它.
Dummy.ascx:
<sc:Sublayout Path="AnotherSublayout.ascx" runat="server" />
Run Code Online (Sandbox Code Playgroud)
AnotherSublayout完全不可见.
我在Lucene索引中有一组课程,其中包含零个或多个可用日期。我正在尝试查询索引,以便返回任何可用日期介于从/到日期之间的课程。
使用我的CourseSearchResultItem中的属性,将该字段作为DateTime对象的集合带回
public class CourseSearchResultItem : SearchResultItem
{
[IndexField("availabledatesforcourse")]
public IEnumerable<DateTime> AvailableDatesForCourse { get; set;}
}
Run Code Online (Sandbox Code Playgroud)
正在构造的查询使用以下代码:
if (courseSearchCriteria.FromDate.HasValue)
query = query.Where(c => c.AvailableDatesForCourse.Any(d => d >= courseSearchCriteria.FromDate.Value));
if (courseSearchCriteria.ToDate.HasValue)
query = query.Where(c => c.AvailableDatesForCourse.Any(d => d <= courseSearchCriteria.ToDate.Value));
Run Code Online (Sandbox Code Playgroud)
运行此命令将产生以下异常:
任何通话中都不支持的lambda。使用的表达式'd =>(d> =值(RCS.Web.Areas.RcsEng.Controllers.CoursesApiController + <> c__DisplayClass10_0).courseSearchCriteria.FromDate.Value)'
我知道这是Sitecore.Linq Any()方法的局限性的结果,但是不确定如何重新创建所需的功能。是否有人有类似的问题可以阐明解决方案?
在内容树中,结构如下
Home
-England
-France
-Germany
Run Code Online (Sandbox Code Playgroud)
有一个子布局(CommentsForm.ascx),用于所有3个页面.当用户浏览"法国"并提交评论时,"评论"项目应保存在"法国"下,依此类推.
在这种情况下,父项(必须在其下创建新项)是动态的.那么,在这种情况下如何获取父项.它是否正确?
protected void btnSubmit_Click(object sender, EventArgs e)
{
Sitecore.Data.Database masterDB = Sitecore.Configuration.Factory.GetDatabase("master");
Item parentItem = Sitecore.Context.Item;
string name = "Comment_" + Sitecore.DateUtil.IsoNow;
TemplateItem template = masterDb.GetTemplate("/sitecore/templates/userdefined/Comment");
using (new SecurityDisabler())
{
//how to go about here??
//newItem["Author"] = txtAuthor.text;
//newItem["CommentText"] = txtComments.Text;
//parentItem.Add("name", template);
}
}
Run Code Online (Sandbox Code Playgroud) 我在我的网站ar-AE中添加了新语言,如果我想访问阿拉伯语网站,我会在网站网址后附加"ar-AE":
但我希望它只与/ ar一起使用
我怎么能用sitecore做到这一点?
我是Sitecore初学者,在使用ASP.NET的Sitecore 8上工作.有一个页面必须进行Ajax调用才能获取数据.
在项目中创建了一个测试Web服务,该服务响应ajax调用成功.这项服务将是一个包装器.
据我所知,我必须在测试服务中使用3个选项之一(在标题中),以获取Sitecore项目并执行操作.
但是所有3个看起来与我相似,并且不确定与哪个相关,以实现我的任务
另外,
1.是否有一个优势.
2. ..何时使用哪一个.
对于我的DEV和TEST,我有一个CM服务器和一个CD服务器.我有一个用于DEV的SQL实例和另一个用于TEST的SQL实例.DEV的CM和CD指向DEV的SQL实例,TEST的CM和CD指向TEST的SQL实例.
如果我以相同的方式使用MongoDB会有任何问题吗?我想只使用DEV的一个实例和TEST的一个实例,其中DEV的CM和CD都指向DEV的MongoDB,TEST的CM和CD都指向TEST的MongoDB.
例如:
<add name="tracking.live" connectionString="mongodb://UserName:Password@mongodbServerDEV/tracking_live" />
Run Code Online (Sandbox Code Playgroud)
<add name="tracking.live" connectionString="mongodb://UserName:Password@mongodbServerTEST/tracking_live" />
Run Code Online (Sandbox Code Playgroud) 我使用Sitecore的8.1版本,并试图创造Templates
,Fields
并Items
以编程方式(保证的情况下,项目的一些场景/模板不存在的),我想设置特定模板的字段shared
或unversioned
,但不能因为:
bool TemplateFieldItem.Shared
属性只有getter
方法(没有setter).
我的代码:
var icon = PageTemplate.AddField("Icon", "Data");
using (new EditContext(icon.InnerItem))
{
icon.Type = "Image";
icon.Sortorder = 3;
icon.Shared = false;
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,只有在 icon.Shared = false;
和icon.Unversioned = false;
我试图从后面的代码中为我的所有页面更改SiteCore 8.0(更新3)中的布局.我正在使用布局解析器管道.我可以调试和查看更改的路径,但无法在UI上获得更新的布局.我通过谷歌搜索看到了各种各样的帖子,他们正在做同样的事情,但那些已经很老了(年龄大于2-3岁).
下面是我的布局解析器管道代码
public class LayoutResolver : HttpRequestProcessor
{
public LayoutResolver()
{
System.Diagnostics.Trace.WriteLine("PipeLine: ctor() has been called");
}
/// <summary>
/// Gets the layout for the page
/// </summary>
/// <param name="args"></param>
public override void Process(HttpRequestArgs args)
{
System.Diagnostics.Trace.WriteLine("PipeLine: This is atleast called");
Assert.ArgumentNotNull(args, "args");
if (!CanProcess())
{
return;
}
Context.Page.FilePath = "/Views/Shared/BusinessLayout_Two.cshtml";
}
private static bool CanProcess()
{
return Context.Database != null
&& !IsCore(Context.Database);
}
private static bool IsCore(Database database)
{
return database.Name == Constants.CoreDatabaseName;
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:showconfig.config在配置中显示我的解析器寄存器.SiteCoreSample.Helpers.LayoutResolver是我的解析器.
<processor …
Run Code Online (Sandbox Code Playgroud) sitecore ×10
sitecore8 ×10
sitecore-mvc ×3
asp.net ×2
c# ×2
sitecore8.1 ×2
linq ×1
lucene.net ×1
sitecore-dms ×1
sitecore-xdb ×1
web-config ×1