orchardcms https://www.e-learn.cn/tag/orchardcms zh-hans Orchard - Search & Indexing issue https://www.e-learn.cn/topic/4012532 <span>Orchard - Search &amp; Indexing issue</span> <span><span lang="" about="/user/30" typeof="schema:Person" property="schema:name" datatype="">☆樱花仙子☆</span></span> <span>2021-01-27 05:36:28</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I have a project completed with Orchard CMS. The all functionalities are implemented through modules. Search module was also working till a few days ago, but suddenly it is stopped to working, "without any reason". The issue is that I can not rebuild/update indexes. When I run indexing, it will only index default list of fields (id, title, body, format, type, author, created, published, modified, culture) but my custom fields are not indexed. I tried everything but without any success. I tried: - Deleting Indexing/Search folder with all files - Reinstalling Search/Indexing/Lucene modules - Rebuilding and rebuilding indexes.... - Clearing solution and rebuilding...</p> <p><strong>I didn't extend any of Orchard modules, they are the same as when I downloaded them.</strong></p> <p>Any advice on this one...?</p> <p><strong>P.S. Yes, I already checked custom fields thats need to be indexed. :)</strong> Thanks,</p> <br /><h3>回答1:</h3><br /><p>If you think the index is corrupted, delete <code>App_data\Sites\Default\Search.settings.xml</code> and <code>App_data\Sites\Default\Indexes</code>, then restart the app pool. You should then be able to rebuild the index.</p> <p>Apparently you already did this, but for others who may not have, you also need to check the fields you want indexed under Settings/Search. This will include the fields in search.</p> <p>But for the fields to be included in search, they need to be indexed first. For this, you need to go to Content/Content Types and edit the content type the fields are on. Check "index this content type for search". Also deploy the settings for each field you want indexed, and check "include in the index".</p> <br /><br /><br /><h3>回答2:</h3><br /><p>You'll need to run the "Recipe" to create the "Search" index.</p> <br /><br /><br /><h3>回答3:</h3><br /><p>It appears that Search + Lucene + Indexing works with Text Fields but not Numeric Fields.</p> <br /><br /><br /><h3>回答4:</h3><br /><p>When the search feature is enabled, the Settings screen in the dashboard displays the fields that will be queried from the index (listed on the Search screen).</p> <p>enter image description here</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/16021915/orchard-search-indexing-issue</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/lucene" hreflang="zh-hans">lucene</a></div> <div class="field--item"><a href="/tag/indexing" hreflang="zh-hans">indexing</a></div> <div class="field--item"><a href="/tag/orchardcms" hreflang="zh-hans">orchardcms</a></div> <div class="field--item"><a href="/tag/field" hreflang="zh-hans">field</a></div> </div> </div> Tue, 26 Jan 2021 21:36:28 +0000 ☆樱花仙子☆ 4012532 at https://www.e-learn.cn NullReference Exception when viewing Content page in Orchard CMS https://www.e-learn.cn/topic/3602167 <span>NullReference Exception when viewing Content page in Orchard CMS</span> <span><span lang="" about="/user/10" typeof="schema:Person" property="schema:name" datatype="">橙三吉。</span></span> <span>2020-04-30 04:52:20</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>In OrchardCMS v1.8.1.0, I receive the following error message when clicking on the Content link (/Admin/Contents/List) file name <strong>Modules\Orchard.MediaLibrary\Views\Parts\Document.SummaryAdmin.cshtml</strong>:</p> <blockquote> <p><strong>Object reference not set to an instance of an object.</strong></p> </blockquote> <pre><code>Source Error: Line 3: @{ Line 4: DocumentPart documentPart = Model.ContentPart; //The following line throws the exception Line 5: var mediaPart = ((ContentItem)Model.ContentItem).As&lt;MediaPart&gt;(); Line 6: } Line 7: </code></pre> <p>Stack trace:</p> <pre><code>[NullReferenceException: Object reference not set to an instance of an object.] ASP._Page_Modules_Orchard_MediaLibrary_Views_Parts_Document_SummaryAdmin_cshtml.Execute() in c:\inetpub\wwwroot\Modules\Orchard.MediaLibrary\Views\Parts\Document.SummaryAdmin.cshtml:5 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +279 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +124 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +124 System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +146 Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:149 Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.&lt;&gt;c__DisplayClass28.&lt;Discover&gt;b__15(DisplayContext displayContext) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:133 Orchard.DisplayManagement.Descriptors.&lt;&gt;c__DisplayClass5.&lt;BoundAs&gt;b__2(DisplayContext displayContext) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:56 Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:181 Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:94 Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:86 Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object&amp; result) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:30 CallSite.Target(Closure , CallSite , Object , Object ) +219 Orchard.Core.Shapes.CoreShapes.ContentZone(Object Display, Object Shape, TextWriter Output) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard.Web\Core\Shapes\CoreShapes.cs:274 [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +76 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +211 Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy.ShapeAttributeBindingStrategy.PerformInvoke(DisplayContext displayContext, MethodInfo methodInfo, Object serviceInstance) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Descriptors\ShapeAttributeStrategy\ShapeAttributeBindingStrategy.cs:65 Orchard.DisplayManagement.Descriptors.&lt;&gt;c__DisplayClass5.&lt;BoundAs&gt;b__2(DisplayContext displayContext) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:56 Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:185 Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:94 Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:86 Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object&amp; result) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:30 CallSite.Target(Closure , CallSite , Object , Object ) +220 ASP._Page_Core_Contents_Views_Content_SummaryAdmin_cshtml.Execute() in c:\inetpub\wwwroot\Core\Contents\Views\Content.SummaryAdmin.cshtml:13 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +125 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +125 System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +147 Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:151 Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.&lt;&gt;c__DisplayClass28.&lt;Discover&gt;b__15(DisplayContext displayContext) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:133 Orchard.DisplayManagement.Descriptors.&lt;&gt;c__DisplayClass5.&lt;BoundAs&gt;b__2(DisplayContext displayContext) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:56 Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:185 Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:94 Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:86 Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object&amp; result) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:30 CallSite.Target(Closure , CallSite , Object , Object ) +220 Orchard.Core.Shapes.CoreShapes.List(Object Display, TextWriter Output, IEnumerable`1 Items, String Tag, String Id, IEnumerable`1 Classes, IDictionary`2 Attributes, String ItemTag, IEnumerable`1 ItemClasses, IDictionary`2 ItemAttributes) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard.Web\Core\Shapes\CoreShapes.cs:687 [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +76 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +211 Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy.ShapeAttributeBindingStrategy.PerformInvoke(DisplayContext displayContext, MethodInfo methodInfo, Object serviceInstance) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Descriptors\ShapeAttributeStrategy\ShapeAttributeBindingStrategy.cs:65 Orchard.DisplayManagement.Descriptors.&lt;&gt;c__DisplayClass5.&lt;BoundAs&gt;b__2(DisplayContext displayContext) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:56 Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:185 Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:94 Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:86 Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object&amp; result) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:30 CallSite.Target(Closure , CallSite , Object , Object ) +220 ASP._Page_Core_Contents_Views_Admin_List_cshtml.Execute() in c:\inetpub\wwwroot\Core\Contents\Views\Admin\List.cshtml:52 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +125 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +125 Orchard.Mvc.ViewEngines.ThemeAwareness.&lt;&gt;c__DisplayClass7.&lt;FindView&gt;b__5(ViewContext viewContext, TextWriter writer, IViewDataContainer viewDataContainer) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\Mvc\ViewEngines\ThemeAwareness\LayoutAwareViewEngine.cs:60 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +380 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +109 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +97 System.Web.Mvc.Async.&lt;&gt;c__DisplayClass21.&lt;BeginInvokeAction&gt;b__1e(IAsyncResult asyncResult) +241 System.Web.Mvc.Controller.&lt;BeginExecuteCore&gt;b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +19 System.Web.Mvc.MvcHandler.&lt;BeginProcessRequest&gt;b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +51 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111 Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in z:\Builds\work\d1eb156ccc3cb14\src\Orchard\Mvc\Routes\ShellRoute.cs:159 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +288 </code></pre> <br /><h3>回答1:</h3><br /><p>Looks like somehow the MediaPart isn't attached to the Document content type, while it expects it to be.</p> <p>Attach the Media part to the Document content type, and set its Stereotype to 'Media' (both can be done in the dashboard).</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/28671198/nullreference-exception-when-viewing-content-page-in-orchard-cms</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/orchardcms" hreflang="zh-hans">orchardcms</a></div> <div class="field--item"><a href="/tag/orchardcms-18" hreflang="zh-hans">orchardcms-1.8</a></div> </div> </div> Wed, 29 Apr 2020 20:52:20 +0000 橙三吉。 3602167 at https://www.e-learn.cn Use OrchardCMS, Umbraco or DotNetNuke as a component in ASP.NET application https://www.e-learn.cn/topic/3348234 <span>Use OrchardCMS, Umbraco or DotNetNuke as a component in ASP.NET application</span> <span><span lang="" about="/user/73" typeof="schema:Person" property="schema:name" datatype="">≡放荡痞女</span></span> <span>2020-02-02 12:59:13</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p><code>OrchardCMS</code>, <code>Umbraco</code> and <code>DotNetNuke</code> are CMSes in .Net galaxy. They work as stand alone applications well. Suppose I have a requirement that need CMS features in an another ASP.NET MVC application. I do not like to implement CMS again in the application. Rather I like to use current CMSes as a component of application.</p> <p>Is it possible at all to use for example OrhcardCMS as a component of my MVC application? It is ideal to have relations between CMS and application itself, for example I can load entities from CMS, update them etc.</p> <p>I know there are integration techniques in .Net. For example ASP.NET Identity integrates with ASP.NET applications in core level, but view (CSHTMLs) must be copied and customized in most cases. Or Hangfire and ELMAH that integrates with an application without need to copy view (cshtml, html, css) to the target application. Indeed it is good to know that integration methods are available regarding plugging CMSes into ASP.NET applications.</p> <br /><h3>回答1:</h3><br /><p>I can tell you more about <strong>Umbraco</strong> as I don't know other CMS as much as this one. There is a whole course / training for those who want to integrate their apps with Umbraco: https://umbraco.com/products-and-support/training/umbraco-application-integration/. So yes, it's possible and it's even suggested way from my perspective to use already done piece of software rather than building the wheel once again.</p> <p>Umbraco is an ASP.NET MVC application. You can use Umbraco components, backoffice, membership and everything else CMSish delivered out of box and still you're able to write and use your business logic, controllers and everything else what you've created inside your ASP.NET MVC / C# app. Still, it's an ASP.NET app, so you can use anything what you want from the .NET world. We're using ELMAH.io for example to take care of logging and keeping the errors in the cloud. We're also using a ton of 3rd party, both open-source and commercial tools and softwares to do multiple things around our web components. Umbraco is not blocking us from using them or anything else. I like to consider Umbraco as a framework or library helping us to deal with content editing and giving us a massive number of opportunities to offer for our clients or editors.</p> <br /><br /><br /><h3>回答2:</h3><br /><p>Speaking for OrchardCMS, there are some questions touching this subject already, see</p> <p>Reusing Orchard's Core to build another extensibility framework</p> <p>Extracting a Module from Orchard</p> <p>If it's possible for you then try to setup Orchard as the base system and move your MVC application in a module. This will be much easier than trying to cut out peaces of Orchard. In return you get amazing possibilites when running Orchard as the underlying framework, e.g. Localization, Modules, Themes, the whole user / role management etc.</p> <p>OrchardCMS 2 is currently developed towards single components that can be reused in any application but it's far from finished yet.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/40501763/use-orchardcms-umbraco-or-dotnetnuke-as-a-component-in-asp-net-application</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/aspnet" hreflang="zh-hans">ASP.NET</a></div> <div class="field--item"><a href="/tag/net" hreflang="zh-hans">.net</a></div> <div class="field--item"><a href="/tag/integration" hreflang="zh-hans">integration</a></div> <div class="field--item"><a href="/tag/umbraco" hreflang="zh-hans">umbraco</a></div> <div class="field--item"><a href="/tag/orchardcms" hreflang="zh-hans">orchardcms</a></div> </div> </div> Sun, 02 Feb 2020 04:59:13 +0000 ≡放荡痞女 3348234 at https://www.e-learn.cn Is it possible to use razor layouts with Orchard CMS and bypass the theming https://www.e-learn.cn/topic/3328095 <span>Is it possible to use razor layouts with Orchard CMS and bypass the theming</span> <span><span lang="" about="/user/28" typeof="schema:Person" property="schema:name" datatype="">拈花ヽ惹草</span></span> <span>2020-01-29 15:31:30</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p><strong>A little bit of context</strong></p> <p>We have a recent MVC4 web application used by a lot people that we would like to port to Orchard CMS. Even though this is an "admin" type of application, we don't want it to be part of the admin section of Orchard. This application is currently live and we would like the move to Orchard to be as invisible as possible to the end-user.</p> <p><strong>Where we are now</strong></p> <p>We followed this answer as how to Integrate existing ASP.NET MVC application with Orchard CMS but we use layouts (Razor not Orchard) and it is not working (by default) with the way Orchard renders pages (the views returned by the controllers actions are displayed without the layouts - _ViewStart.cshtml is ignored). I have tried to specify the path of the layout in the View method but it doesn't work or the path is not good since we are in a module. Is there a way to tell Orchard to use a _layout.cshtml file and bypass Orchard theming?</p> <br /><h3>回答1:</h3><br /><p>It is possible to bypass Orchard themes. Note that I am doing this with MvcMailer, so the outputted e-mail is "templated" HTML with a Layout. I cannot definitively say this works on regular pages, but you can try it. Just slap this in your view:</p> <pre><code>@inherits System.Web.Mvc.WebViewPage&lt;object&gt; @{ Layout = "_Layout.cshtml"; } </code></pre> <p>Caveat: you cannot use the newer @model directiv. I just fall back to the old style and put my model where "object" is:</p> <pre><code>@using Namesapce.ViewModels @inherits System.Web.Mvc.WebViewPage&lt;MyViewModel&gt; </code></pre> <p>Otherwise, it's pretty straightforward to create a Theme and override any of Orchard's shapes. There are two ways I do it: </p> <ol><li>Create a straightforward theme, override shapes (say you want a different Login, just create Login.cshtml in the Theme's ~/View folder), use alternates (use Layout-homepage.cshtml to override the layout for the homepage), have your .css, etc.;</li> <li>Use a couple of tricks to override the theme with code from a module, and create your own views and shapes in a theme folder. You can, for example, have a Layout.cshtml file in your theme with code that displays a shape. However, the shape itself (.cshtml file) lives in your module, which is great for using a dashboard type theme that will call a shape that is named the same in your different modules but shows different content. The code for this is a bit more in-depth. Just ask if you need samples.</li> </ol><br /><br /><br /><h3>回答2:</h3><br /><p><strong>tl;dr</strong> No, it is not possible.</p> <p>I don't like answering my own questions but since Bertrand Le Roy commented my question instead of answering it (no hard feelings) and he is part (or was?) of the Orchard team, I will answer with what I know, until someone comes with a better answer.</p> <p>From what I understand, to be part of an Orchard project is to embrace it all the way, there is no in between. The custom (Orchard) view engine (which works with zones, layouts, widgets, shapes, etc.) cannot be bypassed (fallback to default MVC engine) in a module. As Bertrand suggested, I should convert my project to Orchard theming.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/15347551/is-it-possible-to-use-razor-layouts-with-orchard-cms-and-bypass-the-theming</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/aspnet-mvc" hreflang="zh-hans">asp.net-mvc</a></div> <div class="field--item"><a href="/tag/orchardcms" hreflang="zh-hans">orchardcms</a></div> </div> </div> Wed, 29 Jan 2020 07:31:30 +0000 拈花ヽ惹草 3328095 at https://www.e-learn.cn Access HttpConfiguration in Orchard CMS https://www.e-learn.cn/topic/3300342 <span>Access HttpConfiguration in Orchard CMS</span> <span><span lang="" about="/user/172" typeof="schema:Person" property="schema:name" datatype="">无人久伴</span></span> <span>2020-01-24 20:17:05</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I would like to enable CORS (Cross-Origin Request) in Orchard 1.8.1. I followed this article for the purpose. However, I don't know how to access HttpConfiguration for my WebAPI Controller. I tried to use ControllerContext.Configuration, but it seems to be always NULL.</p> <p>What is the proper method to access HttpConfiguration in Orchard and to call EnableCors()?</p> <p>Thank you in advance.</p> <br /><h3>回答1:</h3><br /><p>As I figured Orchard uses GlobalConfiguration, I created a shell hook impelmenting the IOrchardShellEvents in my module, and inside the Activated method implementation I called System.Web.Http.GlobalConfiguration.Configuration.EnableCors();</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/30285159/access-httpconfiguration-in-orchard-cms</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/orchardcms" hreflang="zh-hans">orchardcms</a></div> <div class="field--item"><a href="/tag/orchardcms-18" hreflang="zh-hans">orchardcms-1.8</a></div> </div> </div> Fri, 24 Jan 2020 12:17:05 +0000 无人久伴 3300342 at https://www.e-learn.cn How to include custom CSS or Javascript on a Content Item in Orchard https://www.e-learn.cn/topic/3298178 <span>How to include custom CSS or Javascript on a Content Item in Orchard</span> <span><span lang="" about="/user/209" typeof="schema:Person" property="schema:name" datatype="">感情迁移</span></span> <span>2020-01-24 15:14:43</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>Sometimes I want to add some custom CSS or Javascript to a page but the HTML editor doesn't handle this gracefully, even when using text dialog.</p> <p>I could use an alternate view but then I have to upload the view file to my host every edit. </p> <p>Any ideas?</p> <br /><h3>回答1:</h3><br /><p>Ok, I found a module (Vandelay.Classy) that does exactly this.</p> <p>http://orchardproject.net/gallery/List/Modules/Orchard.Module.Vandelay.Classy</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/6807939/how-to-include-custom-css-or-javascript-on-a-content-item-in-orchard</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/orchardcms" hreflang="zh-hans">orchardcms</a></div> </div> </div> Fri, 24 Jan 2020 07:14:43 +0000 感情迁移 3298178 at https://www.e-learn.cn How to delete version records of a content item in Orchard? https://www.e-learn.cn/topic/3295761 <span>How to delete version records of a content item in Orchard?</span> <span><span lang="" about="/user/93" typeof="schema:Person" property="schema:name" datatype="">送分小仙女□</span></span> <span>2020-01-24 10:19:12</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I have a Orchard CMS running that is tied to a user synchronization. This sync updates each user overnight and the code begins with</p> <pre><code>... = mContentManager.Get&lt;Orchard.Users.Models.UserPart&gt;(lOrchardUser.ContentItem.Id, Orchard.ContentManagement.VersionOptions.DraftRequired); </code></pre> <p>As you can see <code>VersionOptions.DraftRequired</code> is passed to the <code>Get()</code> method with creates a new draft each time the user is synchronized. It's not intended to create a new draft here so i changed it to <code>VersionOptions.Published</code> which avoids creating a new version record on each call.</p> <p>But issue here is that passing <code>VersionOptions.DraftRequired</code> in the past has created around 120 version records for each user whereas there are around 1000 users in the DB.</p> <p>When i now use <code>IContentManager.Query()</code> it takes considerably longer due to the high amount of versions.</p> <p>My idea is to remove all versions except the published one as i don't need them but <code>IContentManager</code> doesn't provide any version removal option and deleting the records by using <code>IRepository&lt;&gt;</code> causes a NHibernate exception.</p> <p>So my last resort was to use LINQ queries to remove the versions, this did work but i was told that using LINQ in Orchard is not recommended.</p> <p>I wonder whether anyone had any issues with high amounts of version records as the longer the system runs the more data is accumulated and the system is getting slower and slower.</p> <p>So, my questions are</p> <ol><li>is there an Orchard way to remove version records?</li> <li>is there a way to disable versioning?</li> </ol><br /><h3>回答1:</h3><br /><p>As there seems no Orchard way to do this, i deleted the versions with the following LINQ 2 SQL code:</p> <pre><code> public System.Web.Mvc.ActionResult RemoveVersions() { // select user ids, an alternate way is to retrieve user IDs via content manager but this takes a veeeeery long time due // to the need of querying all versions // // var lOrchardUserIDs = mContentManager // .Query&lt;Orchard.Users.Models.UserPart, Orchard.Users.Models.UserPartRecord&gt;(Orchard.ContentManagement.VersionOptions.AllVersions) // .List() // .Select(u =&gt; u.Id) // .ToList() var lOrchardUserIDs = mUserRepository.Fetch(u =&gt; true).Select(u =&gt; u.Id).ToList(); foreach (var lOrchardUserID in lOrchardUserIDs) { var lContentItemVersionRecords = (from r in DataContext.ContentItemVersionRecords where r.ContentItemRecord_id == lOrchardUserID select r).ToList(); if (lContentItemVersionRecords.Count &gt; 1) { foreach (var lContentItemVersionRecord in lContentItemVersionRecords) { if (lContentItemVersionRecord.Number == 1) { if (lContentItemVersionRecords[lContentItemVersionRecords.Count - 1].Published) { lContentItemVersionRecord.Latest = true; lContentItemVersionRecord.Published = true; } } else DataContext.ContentItemVersionRecords.DeleteOnSubmit(lContentItemVersionRecord); } } } DataContext.SubmitChanges(); return Content("Done"); } </code></pre> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/35486133/how-to-delete-version-records-of-a-content-item-in-orchard</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/c" hreflang="zh-hans">c#</a></div> <div class="field--item"><a href="/tag/nhibernate" hreflang="zh-hans">nhibernate</a></div> <div class="field--item"><a href="/tag/version" hreflang="zh-hans">version</a></div> <div class="field--item"><a href="/tag/orchardcms" hreflang="zh-hans">orchardcms</a></div> </div> </div> Fri, 24 Jan 2020 02:19:12 +0000 送分小仙女□ 3295761 at https://www.e-learn.cn Orchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties https://www.e-learn.cn/topic/3284285 <span>Orchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties</span> <span><span lang="" about="/user/133" typeof="schema:Person" property="schema:name" datatype="">时光怂恿深爱的人放手</span></span> <span>2020-01-23 03:05:19</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I'm working on building a custom module in Orchard CMS, and I have the following Controller Action:</p> <pre><code>public ActionResult Inventory() { var models = _repository.Get&lt;MyModel&gt;(); return View(new MyViewModel() { MyModels = models.ToList() }); } </code></pre> <p>Now, when Orchard builds this, an exception occurs, because NHibernate has picked up MyModel because its being looked at as a PartRecord, which I do not want it to be.</p> <p>The exception is method get_Id should be 'public/protected virtual' or 'protected internal virtual'.</p> <p>I can add virtual to the properties, but I want to avoid having NHibernate have any part in looking at this object, it is unnecessary. </p> <p>My question is, how can I add a Model, access that model in a view and suppress Orchard from treating it as a PartRecord? I actually use the model in a separate repository, separate from the Orchard DB.</p> <p>EDIT: Additional Information</p> <p>_repository is an IDbRepository, pointing to my own DB instance MyModel is a POCO for my data. I'm trying avoid putting virtual on the properties in MyModel, I have them in here, to illustrate where I'm trying to avoid them.</p> <pre><code>public interface IDbRepository : IDependency { T Find&lt;T&gt;(long id) where T : class, IActiveRecord; bool Update&lt;T&gt;(T record) where T : class, IActiveRecord; bool Remove&lt;T&gt;(T record) where T : class, IActiveRecord; } public class MyModel : IActiveRecord { [Key] public virtual long Id { get; set; } public virtual int SupplierProductId { get; set; } public virtual int SupplierId { get; set; } public virtual int ProductId { get; set; } } </code></pre> <p>In addition to this, my module does have a settings part that I've created, that does get stored in Orchard DB and is edited in the site settings. I'm using a handler to control that. However, I've tried removing the handler and a few other things to keep Orchard from taking my object into NHibernate.</p> <br /><h3>回答1:</h3><br /><p>Orchard auto-mapping configuration assumes that any class will be mapped if the following conditions are met:</p> <ul><li>the namespace ends with ".Models" or ".Records"</li> <li>there is an <code>Id</code> property, with virtual accessors</li> <li>the class is neither sealed nor abstract</li> <li>the class doesn't implement <code>IContent</code> or inherits from <code>ContentPartRecord</code></li> </ul><p>So if you prevent any of those criteria from being true, you should be good. For instance, defining your classes in a namespace not ending with <code>.Models</code> or <code>.Records</code> should be sufficient.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/7840250/orchard-custom-module-model-being-picked-up-by-nhibernate-requiring-virtual</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/c" hreflang="zh-hans">c#</a></div> <div class="field--item"><a href="/tag/aspnet-mvc-3" hreflang="zh-hans">asp.net-mvc-3</a></div> <div class="field--item"><a href="/tag/nhibernate" hreflang="zh-hans">nhibernate</a></div> <div class="field--item"><a href="/tag/orchardcms" hreflang="zh-hans">orchardcms</a></div> </div> </div> Wed, 22 Jan 2020 19:05:19 +0000 时光怂恿深爱的人放手 3284285 at https://www.e-learn.cn Orchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties https://www.e-learn.cn/topic/3284276 <span>Orchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties</span> <span><span lang="" about="/user/122" typeof="schema:Person" property="schema:name" datatype="">[亡魂溺海]</span></span> <span>2020-01-23 03:05:01</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I'm working on building a custom module in Orchard CMS, and I have the following Controller Action:</p> <pre><code>public ActionResult Inventory() { var models = _repository.Get&lt;MyModel&gt;(); return View(new MyViewModel() { MyModels = models.ToList() }); } </code></pre> <p>Now, when Orchard builds this, an exception occurs, because NHibernate has picked up MyModel because its being looked at as a PartRecord, which I do not want it to be.</p> <p>The exception is method get_Id should be 'public/protected virtual' or 'protected internal virtual'.</p> <p>I can add virtual to the properties, but I want to avoid having NHibernate have any part in looking at this object, it is unnecessary. </p> <p>My question is, how can I add a Model, access that model in a view and suppress Orchard from treating it as a PartRecord? I actually use the model in a separate repository, separate from the Orchard DB.</p> <p>EDIT: Additional Information</p> <p>_repository is an IDbRepository, pointing to my own DB instance MyModel is a POCO for my data. I'm trying avoid putting virtual on the properties in MyModel, I have them in here, to illustrate where I'm trying to avoid them.</p> <pre><code>public interface IDbRepository : IDependency { T Find&lt;T&gt;(long id) where T : class, IActiveRecord; bool Update&lt;T&gt;(T record) where T : class, IActiveRecord; bool Remove&lt;T&gt;(T record) where T : class, IActiveRecord; } public class MyModel : IActiveRecord { [Key] public virtual long Id { get; set; } public virtual int SupplierProductId { get; set; } public virtual int SupplierId { get; set; } public virtual int ProductId { get; set; } } </code></pre> <p>In addition to this, my module does have a settings part that I've created, that does get stored in Orchard DB and is edited in the site settings. I'm using a handler to control that. However, I've tried removing the handler and a few other things to keep Orchard from taking my object into NHibernate.</p> <br /><h3>回答1:</h3><br /><p>Orchard auto-mapping configuration assumes that any class will be mapped if the following conditions are met:</p> <ul><li>the namespace ends with ".Models" or ".Records"</li> <li>there is an <code>Id</code> property, with virtual accessors</li> <li>the class is neither sealed nor abstract</li> <li>the class doesn't implement <code>IContent</code> or inherits from <code>ContentPartRecord</code></li> </ul><p>So if you prevent any of those criteria from being true, you should be good. For instance, defining your classes in a namespace not ending with <code>.Models</code> or <code>.Records</code> should be sufficient.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/7840250/orchard-custom-module-model-being-picked-up-by-nhibernate-requiring-virtual</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/c" hreflang="zh-hans">c#</a></div> <div class="field--item"><a href="/tag/aspnet-mvc-3" hreflang="zh-hans">asp.net-mvc-3</a></div> <div class="field--item"><a href="/tag/nhibernate" hreflang="zh-hans">nhibernate</a></div> <div class="field--item"><a href="/tag/orchardcms" hreflang="zh-hans">orchardcms</a></div> </div> </div> Wed, 22 Jan 2020 19:05:01 +0000 [亡魂溺海] 3284276 at https://www.e-learn.cn Orchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties https://www.e-learn.cn/topic/3284268 <span>Orchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties</span> <span><span lang="" about="/user/232" typeof="schema:Person" property="schema:name" datatype="">旧巷老猫</span></span> <span>2020-01-23 03:04:26</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I'm working on building a custom module in Orchard CMS, and I have the following Controller Action:</p> <pre><code>public ActionResult Inventory() { var models = _repository.Get&lt;MyModel&gt;(); return View(new MyViewModel() { MyModels = models.ToList() }); } </code></pre> <p>Now, when Orchard builds this, an exception occurs, because NHibernate has picked up MyModel because its being looked at as a PartRecord, which I do not want it to be.</p> <p>The exception is method get_Id should be 'public/protected virtual' or 'protected internal virtual'.</p> <p>I can add virtual to the properties, but I want to avoid having NHibernate have any part in looking at this object, it is unnecessary. </p> <p>My question is, how can I add a Model, access that model in a view and suppress Orchard from treating it as a PartRecord? I actually use the model in a separate repository, separate from the Orchard DB.</p> <p>EDIT: Additional Information</p> <p>_repository is an IDbRepository, pointing to my own DB instance MyModel is a POCO for my data. I'm trying avoid putting virtual on the properties in MyModel, I have them in here, to illustrate where I'm trying to avoid them.</p> <pre><code>public interface IDbRepository : IDependency { T Find&lt;T&gt;(long id) where T : class, IActiveRecord; bool Update&lt;T&gt;(T record) where T : class, IActiveRecord; bool Remove&lt;T&gt;(T record) where T : class, IActiveRecord; } public class MyModel : IActiveRecord { [Key] public virtual long Id { get; set; } public virtual int SupplierProductId { get; set; } public virtual int SupplierId { get; set; } public virtual int ProductId { get; set; } } </code></pre> <p>In addition to this, my module does have a settings part that I've created, that does get stored in Orchard DB and is edited in the site settings. I'm using a handler to control that. However, I've tried removing the handler and a few other things to keep Orchard from taking my object into NHibernate.</p> <br /><h3>回答1:</h3><br /><p>Orchard auto-mapping configuration assumes that any class will be mapped if the following conditions are met:</p> <ul><li>the namespace ends with ".Models" or ".Records"</li> <li>there is an <code>Id</code> property, with virtual accessors</li> <li>the class is neither sealed nor abstract</li> <li>the class doesn't implement <code>IContent</code> or inherits from <code>ContentPartRecord</code></li> </ul><p>So if you prevent any of those criteria from being true, you should be good. For instance, defining your classes in a namespace not ending with <code>.Models</code> or <code>.Records</code> should be sufficient.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/7840250/orchard-custom-module-model-being-picked-up-by-nhibernate-requiring-virtual</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/c" hreflang="zh-hans">c#</a></div> <div class="field--item"><a href="/tag/aspnet-mvc-3" hreflang="zh-hans">asp.net-mvc-3</a></div> <div class="field--item"><a href="/tag/nhibernate" hreflang="zh-hans">nhibernate</a></div> <div class="field--item"><a href="/tag/orchardcms" hreflang="zh-hans">orchardcms</a></div> </div> </div> Wed, 22 Jan 2020 19:04:26 +0000 旧巷老猫 3284268 at https://www.e-learn.cn