[英]Creating 2sxc Content Template
I followed the steps as per the following guide tutorial: http://2sxc.org/en/Learn/Getting-started-with-creating-stuff/First-Content-Template But I am having trouble with one or two issues. 我按照以下指南进行了操作: http : //2sxc.org/en/Learn/Getting-started-with-creating-stuff/First-Content-Template但是我遇到一个或两个问题。
After pasting in the Template.txt code: 粘贴Template.txt代码后:
<div class="sc-element"> @Edit.Toolbar(Content) <!--- Edit toolbar --> <div class="co-person-image col-sm-4"> @if (!String.IsNullOrEmpty(Content.Photo)) { <img src="@Content.Photo?w=350" alt="@Content.Name" class="img-responsive" /> } else { <div class="co-person-placeholder"></div> } </div> <div class="co-person-text col-sm-8"> <p> <strong>@Content.Name</strong><br /> @if (!String.IsNullOrEmpty(Content.Position)) { @Content.Position<br /> } </p> <p> @if (!String.IsNullOrEmpty(@Content.EMail)) { <a href="mailto:@Content.EMail">@Content.EMail</a><br /> } @if (!String.IsNullOrEmpty(Content.Phone)) { <text>@Content.Phone<br /></text> } </p> @Html.Raw(Content.Description) </div> </div>
I am not seeing any placeholder and when I upload an image using ADAM it too wont appear to screen? 我没有看到任何占位符,当我使用ADAM上传图像时,它也不会出现在屏幕上吗?
Not sure what I am doing wrong but would really appreciate some help on this as I also tried simply pasting in code from another one of your bootstrap templates into my new template but am getting the following error: 不确定我做错了什么,但是对此我将非常感谢,因为我还尝试将代码从另一个引导模板粘贴到新模板中,但是出现以下错误:
Error: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The best overloaded method match for 'string.IsNullOrEmpty(string)' has some invalid arguments at CallSite.Target(Closure , CallSite , Type , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at ASP._Page_Portals_0_2sxc_Content__text_block_image_block_12_cshtml.Execute() in d:\\Inventise\\trunk\\Customers\\St Josephs Foundation\\Projects\\Website\\Sources\\DNN-Root\\Portals\\0\\2sxc\\Content_text block_image block_12.cshtml:line 26 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at ToSic.SexyContent.Engines.RazorEngine.RenderTemplate() in C:\\Projects\\2SexyContent\\Web\\DesktopModules\\ToSIC_SexyContent\\2Sexy Content Razor\\RazorEngine.cs:line 76 at ToSic.SexyContent.Engines.EngineBase.Render() in C:\\Projects\\2SexyContent\\Web\\DesktopModules\\ToS
错误:Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:“ string.IsNullOrEmpty(string)”的最佳重载方法匹配在System.Dynamic.UpdateDelegates.UpdateAndExecute2的CallSite.Target(Closure,CallSite,Type,Object)具有一些无效参数。 T0,T1,TRet](CallSite网站,T0 arg0,T1 arg1)位于ASP._Page_Portals_0_2sxc_Content__text_block_image_block_12_cshtml.Execute(),位于d:\\ Inventise \\ trunk \\ Customers \\ St Josephs Foundation \\ Projects \\ Website \\ Sources \\ DNN-Root \\ Portals 0 \\ 2sxc \\ Content_text block_image block_12.cshtml:第26行,位于System.Web.WebPages.WebPageBase.ExecutePageHierarchy()位于System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext,TextWriter writer,WebPageRenderingBase startPage)在ToSic.SexyContent.Engines C:\\ Projects \\ 2SexyContent \\ Web \\ DesktopModules \\ ToSIC_SexyContent \\ 2Sexy Content Razor \\ RazorEngine.cs:第76行的。 Web \\ DesktopModules \\ ToS IC_SexyContent\\SexyContent\\Engines\\EngineBase.cs:line 89 at ToSic.SexyContent.SxcInstance.Render() in C:\\Projects\\2SexyContent\\Web\\DesktopModules\\ToSIC_SexyContent\\SexyContent\\SxcInstance.cs:line 200
IC_SexyContent \\ SexyContent \\ Engines \\ EngineBase.cs:第89行,位于C:\\ Projects \\ 2SexyContent \\ Web \\ DesktopModules \\ ToSIC_SexyContent \\ SexyContent \\ SxcInstance.cs:第200行的ToSic.SexyContent.SxcInstance.Render()
The path mentioned in the above error message appears wrong but I don't know where this can be amended? 上面的错误消息中提到的路径显示错误,但我不知道可以在哪里修改?
I would appreciate help on this issue. 在此问题上的帮助,我将不胜感激。 Regards
问候
I'll try to guide you through it, but I'm guessing you forgot to set a demo-item. 我会尝试指导您完成操作,但是我猜您忘记设置演示项目了。
The demo-item is used to show data on a template, till a user adds his own. 演示项目用于在模板上显示数据,直到用户添加自己的数据为止。 So it's really important to create an item in the admin UI (Step 1.5) and assign it to the template (Step 1.5.1).
因此,在管理用户界面中创建一个项目(步骤1.5)并将其分配给模板(步骤1.5.1)非常重要。 This allows the template to render, before you add any data to a page :).
在将任何数据添加到页面之前,这允许模板呈现:)。
If you don't have a demo-item, the template assumes it can't render, and will show a message that it doesn't have data yet - or it will try to render, and fail with errors like the one above. 如果您没有演示项目,则模板会假定它无法渲染,并会显示一条消息,提示它尚无数据-否则它将尝试渲染,并因上述错误而失败。
Did that help? 有帮助吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.