Oct 30 2013

Orchard CMS – code or UI when doing custom extensions?

        <p>I have a question for professional Orchard developers?  </p>
Given that I can create new ContentTypes and ContentParts using the UI, when should you use the UI to create new Content Types/Parts versus creating a custom module and coding everything. What are the tradeoffs? Is there a time to combine the approaches and create some of your content types/parts in the UI and then extend them further using code? What are the advantages of each method? (For example, it seems to me that deploying changes is easier using code...but still possible using the UI using the Import/Export module? UI it seems you get things done pretty quickly, but is less flexible and portable than writing code? What are the things you HAVE to do in code?
Oct 29 2013

Great article on SQL Command utility.

I thought I knew about the Sql Server sqlcmd utility … until I read this article…


One of the coolest things I learned is that DOS has an “if exist” command.


Oct 13 2013

Comment by Seth Spearman on Weird behavior when opening web project in Visual Studio 2012

I am Not sure at this time if your answer is going to resolve my problem. But it gives me some things to try and incorporates all the other answers as well. Bounty given.

Oct 06 2013

Things to remember about extending Orchard CMS

  1. Use the Orchard command line to create a module   —
    Type “help command” to get a list of command available in the orchard console.
    Enable code generation – type “feature enable Orchard.CodeGeneration”
    Type “help codegen module” to get usage on creating a module
    Type “codegen  module <projectname> /IncludeInSolution:true” to create your module.
  2. Use the Orchard command line to create a migration —
    Type “help codegen datamigration” to get usage
    Type “codegen datamigration <projectname> to create a migration for your project.
  3. To deploy an Orchard site —
    Open a VS command prompt at the root of your build sources
    type “build Precompiled”…this will create “build” and “buildtasks” folders
    The deployment source is in “build\Precompiled”
    Be sure that the App_Pool security context has write permissions on App_Data, and a Media folder (which you will have to create) of the IIS root
    NOTE -  http://docs.orchardproject.net/Documentation/Building-and-deploying-Orchard-from-a-source-code-drop
  4. Info on handling existing databases http://orchard.codeplex.com/discussions/438078
  5. Handling 1-1 and n-n db relaitonships in Orchard… https://github.com/OrchardCMS/OrchardDoc/blob/master/Documentation/Creating-1-n-and-n-n-relations.markdown

TO MAKE A NEW ORCHARD CONTENT PART…Lets call it the Xyz part

  1. Create a XyzPart  class.  Inherit from ContentPart<XyzPartRecord>
    This is a simple poco with property setters and gettters for each field in the part.
    The GET wll return Record..<FieldName>  like get {return Record.ItemCode; }
    The SET does the same like  set { Record.ItemCode = value;}
    Using Orchard and Orchard.ContentManagement
  2. Create a XyzPartRecord (per the reference in step 1) class that inherits from ContentPartRecord. 
    It uses matching virtual properties (so NHibernate can deal with it) like …
      public virtual string ItemCode{ get; set; }
    Using Orchard and Orchard.ContentManagement.Records
  3. Add migrations for updating the database.  
    Add a Create method.
    Use SchemaBuild.CreateTable to create the table and associate the content part with the record using lambdas like this…
    SchemaBuilder.CreateTable(“XyzPartRecord”, table=>table.ContentPartRecord().Column<string>(“ITemCode”));
  4. Creae a XyzPartHandler class which inherits from ContentHandler…
    This class just wires up the IRepository for the part like this…
    CTOR –
    publci XyzPartHandler(IRepository<XyzPartRecord> repository)  {
    Filters.Add(StorageFilter.For(repository));   }
    Using Orchard.Data and Orchard.ContentManagement.Handlers
    The handler plugs into the event lifecycle of a part and is typically used to wire up events.
  5. Please note that a Handler can hook into any part of the Part lifecycle.
    Add a XyzFeatureEventHandler file.
    Inherit from IFeatureEventHandler….implement the interfaces as necessary.  Notice that it has very generous Event Model…Number of points in the lifecycle.
    Delete  the not implemented exception we don’t need.
  6. Create XyzPartDriver which inherits from ContentPartDriver<XyzPart>
    The Driver serves the same function as an MVC Controller except that it operates at the part level rather than the page request level. 
  7. Creaet an XyzService class that Inherits from IXyzService which is an interface declard in the same file (I think this design is to enable use with an IOC).
    At the ver least add an Update method called something like UpwardXyzFor ContentItem and pass in a viewmodel and ContentItem.