恢复Orchard admin 管理密码

发布于:
Orchard CMS

如果你一不小心忘记了Orchard的帐户密码,该怎么恢复,如果没有连数据库的密码一起忘记或者有办法登上数据库那还很好的试解决,Orchard 提供了非常方便的方法。

我将使用在本地SQLSERVER数据库,其他数据库会有细微的差别,但都能够完成。

Using shapes as Html helpers in Orchard

发布于:
Orchard CMS

Orchard shapes are the basic building block of the whole rendered UI. They are ordinary, although dynamically discovered and created by Orchard framework, Razor (.cshtml) view files. One of the coolest (and also the one that generates most of the beginners’ problems) thing about Orchard is it’s flexible nature by extensive use of C# 4.0 dynamic objects.

Suppose you have the following line of code:

@Display(New.MyShape(Text: “someText”, SomeProperty: someObject))

Orchard CMS中缓存的使用

发布于:
Orchard CMS

Orchard缓存的优点和机制:

多级缓存:

Orchard缓存的多级缓存控制机制是非常值得称道的,他可以将有依赖关系的对象自动关联起来进行自动控制,比如:A对象是从B对象得到的,这时候如果B对象过期,那么A对象也会自动过期;这里可以看到所有的缓存是存放在一个ConcurrentDictionary结构里的,这个ConcurrentDictionary可以保证线程安全。

使用简单:

Orchard抛弃传统的传统get set的缓存方式,Orchard缓存的管理都只提供了一个Get方面没有其他Add、Update等等的东西.从缓存类里Get的方法的实现我们知道, 当程序无法根据TKey获取到结果的时候,就会创建一个新的结果同时保存到缓存里。

过期机制:

Orchard的缓存拥有强大的过期机制,实际上他的根本是一个失效令牌的机制,令牌只有一个属性: bool IsCurrent 如果IsCurrent==false时Cache过期,而客户代码可以通过实现不同的IVolatileProvider来实现各种不同的过期机制。

优雅的代码风格:

在Orchard.Framework的Caching目录下有18个文件,有兴趣的同学可以读读源码,写的非常不错。

Orchard 删除的内容 不会在数据库中删除相关的部分记录

发布于:
Orchard CMS

From Orchard Codeplex

我注意到,当我使用如下代码删除的内容项目,它不会删除连接到该内容项的任何部分的现有数据库记录。 例如,AutoroutePartRecord和TitlePartRecord。

_contentManager.Remove(contentItem)

这可能是是移除和彻底删除的想法差异,当您通过ContentManager删除的内容项目时 ,它只是清除在所有版本的发布时间和最新的标志,但留下完整的记录,只是对任何查询透明。 它不是一个记录删除而像一个回收站,数据仍然存在的情况下删除内容是不是你的工作流程的结束。 这是和版本记录您发布版本时总体思路相同,旧版本记录既不是最新的,也不发布时间,但他们像维基,历史悠久的审计,恢复到过去,等场景实际存在。好像这个叫什么软删除。

这在大多数情况下是一个良好的方案,但应该有一个可能,需要永久地删除的内容记录,只是你不一定需要它。

所以,我们得到一个处理办法。ContentHandler中添加OnRemove事件,彻底的消灭它。

public class SchoolHandler : ContentHandler
    {
        public SchoolHandler (IRepository schoolPartRepository)
        {
            Filters.Add(StorageFilter.For(schoolPartRepository));
            OnRemoved((context, part) =>
            {
                schoolPartRepository.Delete(part.Record);
            });
        }
    }

最后引用一个帖子的内容,来说明一般情况下没有必要非得删除它。

磁盘空间时下真的很便宜,甚至在托管计划您的网站可能会工作了很长很长的时间,都难以达到你的主机的空间限制。而且那些数据一般而言,对性能的影响也微乎其微,而且也可做其他优化用空间来换取时间(性能)。如果这真成为一个问题,做清理模块可能将不得不直接在NHibernate做一些结构混乱的东西,但它应该是相当简单的。 但在一般情况下,软删除是越来越普遍,因为他们提供了许多优点。

 

Orchard Date and time culture formatting in po(时间格式化)

发布于:
Orchard CMS

localization files are missing the format used to display published date.

default Parts.Common.Metadata.cshtml declares this :

<div class=”published”>@Display.PublishedState(createdDateTimeUtc: Model.ContentPart.CreatedUtc, publisheddateTimeUtc: Model.ContentPart.PublishedUtc)</div>

And PublishedState shape is declared as follows (in CoreCommonShape.cs) :

return Display.DateTime(DateTimeUtc: createdDateTimeUtc);

And, finally, DateTimeShape.DateTime is :

Orchard 学习随记,Module创建、安装、卸载命令

发布于:
Orchard CMS
Module 卸载(使用命令行):

package create <extensionName> <path>
    Create a package for the extension <extensionName>
    (an extension being a module or a theme).
    The package will be output at the <path> specified.
    The default filename is Orchard.[Module|Theme].<extensionName>.<extensionVersion>.nupkg.
    For example, "package create SampleModule c:temp" will create the package
    "c:tempOrchard.Module.SampleModule.1.0.0.nupkg".

package install <packageId> <location> /Version:<version>
        Install a module or a theme from a package file.

package uninstall <packageId>
    Uninstall a module or a theme.
    The <packageId> should take the format Orchard.[Module|Theme].<extensionName>.
    For example, "package uninstall Orchard.Module.SampleModule" will uninstall the Module under the "~/Modules/SampleModule" directory and
    "package uninstall Orchard.Theme.SampleTheme" will uninstall the Theme under the "~/Themes/SampleTheme" directory.

 

Orchard CMS Taxonomy Term Autoroute Token Slug v2.0

发布于:
Orchard CMS

From :http://sheltonial.blogspot.com.au/2013/11/orchard-cms-taxonomy-term-autoroute.html

This is a new and improved solution to my original post http://sheltonial.blogspot.com.au/2013/10/orchard-cms-taxonomy-term-autoroute.html.

The purpose of this post is to provide a method of returning a full taxonomy term path slug as a token in Orchard CMS. I am currently using this solution in Orchard 1.7.1 as of changeset 91d0048f2796f093a8cefe2111ff013818d220fb.

 

The problem with the previous solution was that it only rendered the 1 selected taxonomy term into the token result, which was great if you were working with the root terms, but as soon as you went deeper it did not render the full taxonomy term path into the token result.

The following solution allows a full taxonomy term path to be slugified and rendered into a token result.