我正在寻找一个在MVC中运行的动态占位符解决方案.对于WebForms,至少有两个关于此"模式"的描述:
我还发现这个博客解释了如何使用MVC:
首先,我尝试使用MVC blogpost(SitecoreHelper的扩展)中的技术实现Techphoria的方法(使用GUID),并且我还尝试实现最后描述的方法(使用增量为Column_1,Column_2等的数字后缀).
通过我尝试的所有变化,我没有成功创建一个可行的解决方案.我的占位符没有正确命名(我最终得到了奇怪的占位符结构,或占位符重复自己).
如果不了解我的尝试细节,我想知道是否有其他人准备好了我可以使用的工作解决方案.
如果我找不到已经有效的解决方案,我会更详细地描述我的问题,看看我是否可以使用它.
我们有一个渲染列出当前项目中TreeSelect中的选定项目.我们称之为"标签"(1)
我们在组件中添加了一个Field Editor按钮,让编辑器更改所选项.(2)(如例如添加自定义组件所述)
当编辑器单击(2)编辑器窗口(3)时,它将在对话框中打开.编辑器可以使用TreeSelect选择不同的项目(在我们的例子中称为标签).
当编辑器按下ok按钮(4)时,将设置值.
现在来问题:
当编辑器按下保存按钮时,这些值实际上是在它们被存储时设置的,但我们希望页面(1)上的列表在编辑器按下确定按钮(4)时立即反映设置项目,即在实际需要之前保存整个项目.
我们如何实现这一目标?
(我与Sitecore支持联系,但到目前为止我还没有得到任何答案...)
更新 经过与支持人员的大量对话后,我们仍然没有有用的解决方案.
我们尝试将其转换为显示链接的字段渲染器.有用的是:
<command name="webedit:fieldeditor" type="Sitecore.Shell.Applications.WebEdit.Commands.FieldEditor, Sitecore.Client"/>
并设置单击按钮webedit:fieldeditor(command={3473DDA1-2983-493C-AF7A-054C75AA7AD3},fields=NameOfField
指向guelf指向其自身的位置,并在其上设置"图标".)什么不起作用是:
支持的问题变成了一个功能请求,让服务器参与渲染字段,而不仅仅是向JavaScript发送新值来更新它.服务器执行第一次渲染,因此当它已经参与更新时,应该允许它在以下时间进行渲染.
我们决定现在不花更多的时间在这上面(我们还有其他事情要做.)并且编辑经验不好,因为在编辑器实际保存项目之前,字段不会更新.
我们仍然没有适合这个问题的解决方案.如果你想继续努力并希望引用我的问题,那就是439059.
当我使用时,我在Visual Studio中收到此错误@Html.Sitecore
:
"System.Web.Webpages.Html.Htmlhelper"不包含"Sitecore的"和最佳推广方法重载"Sitecore.Mvc.HtmlHelperExtensions.Sitecore(System.Web.Mvc.HtmlHelper)"的定义有一些无效arguments.`
但是,一旦部署,它确实运行没有任何问题.
我正在使用Sitecore 7.2和MVC 5.1.
我读过的文章涉及类似的错误消息,请谈谈文件夹文件的system.web.webPages.razor
部分.这就是它在我的解决方案中的表现.Views
web.config
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
Run Code Online (Sandbox Code Playgroud)
最初我以为我只需要重新启动VS,但这不起作用.有没有人有什么建议.
编辑 这是标准的Sitecore 7.2安装,因此具有以下绑定重定向:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" xmlns="urn:schemas-microsoft-com:asm.v1"/>
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.1.0.0" xmlns="urn:schemas-microsoft-com:asm.v1"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" xmlns="urn:schemas-microsoft-com:asm.v1"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" xmlns="urn:schemas-microsoft-com:asm.v1"/>
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
另外,在查看visual studio的输出时,还有一个我之前没有发现的错误:
Instance argument: cannot convert from 'System.Web.WebPages.Html.HtmlHelper' to 'System.Web.Mvc.HtmlHelper'
编辑2
我不再认为这是Sitecore MVC问题.我得到了类似的错误@Html.ActionLink("xxx", "xxx")
.其他人在VS2012中看到了这个问题,但我使用的是2013年.
编辑3 …
有人可以帮我澄清何时使用以下内容(它们看起来与我相似并且令人困惑):
我正在尝试将控制器返回的视图静态添加到我的视图中.在标准MVC中,我会做类似下面的事情.
@{Html.RenderAction("Product", "ProductListing", new {productId = product.ItemId});}
Run Code Online (Sandbox Code Playgroud)
这是我的控制器
[System.Web.Http.HttpGet]
public ActionResult Product(ID productId)
{
var product= _productRepositorty.GetProduct(productId);
return View("~/Views/Product/ProductDetails.cshtml", product);
}
Run Code Online (Sandbox Code Playgroud)
所以使用Sitecore渲染助手我有下面的内容,其中ID是Sitecore中的渲染项目,指向上面的控制器和操作.但是我无法将productId作为参数传递给Product操作(productId始终为null).这是将变量传递给另一个动作的正确方法吗?
@Html.Sitecore().Rendering("{AA6C2188-1897-4577-BE0A-25DD2BBA8AF1}", new { productId = product.ItemId })
Run Code Online (Sandbox Code Playgroud) 我有这个与Tracker有关的问题.
[InvalidOperationException: Tracker.Current is not initialized]
Sitecore.Analytics.Pipelines.StartAnalytics.StartTracking.Process(PipelineArgs args) +304
(Object , Object[] ) +74
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +484
Sitecore.Analytics.Pipelines.StartAnalytics.StartAnalyticsPipeline.Run() +293
Sitecore.Mvc.Analytics.Pipelines.MvcEvents.RequestBegin.StartTracking.Process(RequestBeginArgs args) +139
(Object , Object[] ) +74
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +484
Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +184
Sitecore.Mvc.Routing.RouteHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +74
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +923
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +157
Run Code Online (Sandbox Code Playgroud)
在web.config我是
enableTracking = "真"
如果我设置为false它可以工作,但没有跟踪
我正在从这里学习Sitecore中的Controller渲染.
我创建了一个简单的控制器(HelloWorld)和相关视图(Index.schtml).在Sitecore Explorer的渲染部分中映射它(使用Name PageContent)并在Sitecore Explorer的内容部分中的Home Item中添加渲染项目.但是当我浏览它时,它会给出错误.
The controller for path '/' was not found or does not implement IController.
Run Code Online (Sandbox Code Playgroud)
我读过的所有帖子都与Asp .Net MVC有关..但我有与Sitecore MVC有关的问题
Sample.html(Sitecore Explorer渲染部分中的页面内容)
@using Sitecore.Mvc
<html>
<body>
@Html.Sitecore().Placeholder("content")
<p>Today's date is @DateTime.Now.ToShortDateString()</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
只有这条线给出了问题
@Html.Sitecore().Placeholder("content")
Run Code Online (Sandbox Code Playgroud)
如果我删除此行...它工作正常,浏览器上的页面显示日期和时间
的index.html
<p>Hello from Controller -todays Date is @DateTime.Now.ToString()</p>
Run Code Online (Sandbox Code Playgroud)
调节器
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MVC.Controllers
{
public class HelloWorldController : Controller
{
//
// GET: /HellowWorld/
public ActionResult Index()
{
return View();
} …
Run Code Online (Sandbox Code Playgroud) 我有一个Sitecore站点,在我的两个CD服务器上,Url.Action
返回一个空字符串.这适用于本地和其他9个服务器,从开发到产品,CD和CM.
部署自动化确保将完全相同web.config
的部署到所有环境中; 同样适用于所有其他配置.
我的控制器继承SitecoreController
正确.这不会与某个控制器或操作隔离,所有控制器和操作都会发生这种情况.
什么会Url.Action
在一个环境中返回一个空字符串而不是其他环境,使用相同的代码?
我已经从Sitecore 7.5升级到Sitecore 8,并且在尝试访问内容编辑器时出现错误.
'/'应用程序中的服务器错误.
值不能为空.
参数名称:fieldNameTranslator
描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.异常详细信息:System.ArgumentNullException:Value不能为null.参数名称:fieldNameTranslator
源错误: 在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息.
[ArgumentNullException:Value不能为null.参数名称:fieldNameTranslator] Sitecore.ContentSearch.Linq.Solr.SolrIndexParameters..ctor(IIndexValueFormatter> valueFormatter,IFieldQueryTranslatorMap`1 fieldQueryTranslators,> FieldNameTranslator fieldNameTranslator,IExecutionContext [] executionContexts,> IFieldMapReaders fieldMap,Boolean convertQueryDatesToUtc)+310
Sitecore.ContentSearch.SolrProvider.LinqToSolrIndex`1..ctor(SolrSearchContext> context,IExecutionContext [] executionContexts)+192 Sitecore.ContentSearch.SolrProvider.SolrSearchContext.GetQueryable(IExecutionCo> ntext [] executionContexts)+83 Sitecore.ContentTesting.ContentSearch.TestingSearch .GetRunningTests()+ 637 Sitecore.ContentTesting.Data.SitecoreContentTestStore.GetActiveTests(DataUri> hostItemDataUri,String searchText)+252 Sitecore.ContentTesting.Pipelines.GetContentEditorWarnings.GetContentTestingWar> nings.Process(GetContentEditorWarningsArgs args)+247(Object,Object [] )+141 Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)+365 Sitecore.Shell.Applications.ContentManager.Editor.GetWarnings(Boolean> hasSections)+271 Sitecore.Shell.Applications.ContentManager.Editor.Render(RenderContentEditorArg> s args,Control parent)+178 Sitecore.Shell.Applications.ContentManager.ContentEditorForm.RenderEditor(Item> item,Item root,Control parent,Boolean showEditor)+231 Sitecore.Shell.Applications.ContentManager.ContentEditorForm.UpdateEditor (Item> folder,Item root,Boolean showEditor)+374 Sitecore.Shell.Applications.ContentManager.ContentEditorForm.Update()+411 Sitecore.Shell.Applications.ContentManager.ContentEditorForm.OnPreRendered(Even> tArgs e)+212Boolean showEditor)+374 Sitecore.Shell.Applications.ContentManager.ContentEditorForm.Update()+411 Sitecore.Shell.Applications.ContentManager.ContentEditorForm.OnPreRendered(Even> tArgs e)+212Boolean showEditor)+374 Sitecore.Shell.Applications.ContentManager.ContentEditorForm.Update()+411 Sitecore.Shell.Applications.ContentManager.ContentEditorForm.OnPreRendered(Even> tArgs e)+212
它突然间停止了工作.我不知道出了什么问题,是什么导致了这种情况:
无法实例化事件处理程序.键入:Sitecore.Publishing.HtmlCacheClearer.方法:ClearCaches(方法:Sitecore.Events.Event + EventSubscribers.Add(String eventName,XmlNode configNode)).
我尝试了所有可以使它工作的东西,但事实并非如此
任何人都可以告诉我这个的原因以及可能的解决方案.我是Sitecore的新手.
更新publish:end
和publish:end:remote
<event name="publish:end">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCaches">
<sites hint="list">
<site>website</site>
</sites>
</handler>
</event>
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCaches">
<sites hint="list">
<site>website</site>
</sites>
</handler>
</event>
Run Code Online (Sandbox Code Playgroud) sitecore-mvc ×10
sitecore ×9
asp.net-mvc ×4
sitecore8 ×4
c# ×2
sitecore6 ×2
sitecore7.2 ×2
.net ×1
asp.net ×1
controller ×1
razor ×1
rendering ×1
sitecore7.1 ×1
solr ×1