简体   繁体   English

创建2sxc内容模板

[英]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但是我遇到一个或两个问题。

  1. When I get to Step 2.2 Add the Demo Template by pasting in the Template.txt file into my newly created Template .cshtml file, I am not seeing as expected with my Heading (Content.Title) and my Call to Action button/link (Content.LinkText) are not appearing on screen. 转到步骤2.2时,通过将Template.txt文件粘贴到新创建的Template .cshtml文件中来添加演示模板,但标题(Content.Title)和号召性用语按钮/链接( Content.LinkText)没有出现在屏幕上。 This is preventing me from creating even the most simple of templates 这使我无法创建最简单的模板
  2. 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.

相关问题 DNN 2sxc Razor模板-如果用户已通过身份验证 - DNN 2sxc Razor template - if user is authenticated 是否可以从 DNNSharp 的 Action Form 或 Action Grid 获取内容或令牌并将其显示在 2sxc 模板中? - Is it possible to get content or tokens from DNNSharp's Action Form or Action Grid and display it inside of a 2sxc template? 从ADAM文件管理器获取2sxc模板中的DNN FileID - Getting DNN FileID in 2sxc Template from ADAM File Manager 2sxc | 将第二个按实体过滤的下拉列表添加到模板应用 - 2sxc | Add second filter by entity dropdown to template app 移动 2sxc<script> to external file when it has razor content - Move 2sxc <script> to external file when it has razor content 如何使用 2sxc 和 ac# razor 模板将 CSS 类的动态列表添加到 div? - How can I add a dynamic list of CSS classes to a div using 2sxc and a c# razor template? 如何使用 C# razor 模板仅获取唯一值以显示在 2sxc 列表中? - How do I only get unique values to appear in a 2sxc list with a C# razor template? 如何在 2sxc razor 模板中输出项目的创建、发布和修改日期/时间? - How can I output the item’s creation, published, and modified date/time in a 2sxc razor template? 如何在 c# razor 中将 OpenGraph 和 Twitter Cards 合并到 2sxc 详细信息模板中? - How can I incorporate OpenGraph and Twitter Cards into a 2sxc details template in c# razor? 如何从 2sxc 内容字段中 output 页面 ID 而不是页面 URL ? - How do I output the page ID instead of the page URL from a 2sxc Content field?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM