Core Recipe - Blog Post Not 'Draftable' (Publish Now Missing)

Topics: Core, Customizing Orchard, Installing Orchard, Troubleshooting
Nov 14, 2011 at 1:32 AM

Okay, so I've been planning to get real serious in Orchard here so I'm playing with the recipes.  I've installed the "Core" in hopes of building the minimum I needed for a basic site.  I learned that I turned on almost all the features of the "default" recipe however I've found one major issue.

My default installs have a "Publish Now" button for blogposts and my Core recipe does not.  I found this which helped guide me to the problem (but not the solution):

http://chrisbower.com/2011/02/21/draftable-content-or-how-to-enable-the-publish-button/

So I've found that the difference is that the "Publish Now" button only shows up if the ContentType is Draftable.  Digging some more I found this:

Core Recipe:

  <Metadata>
    <Types>
      <Page ContentTypeSettings.Draftable="True" />    
    </Types>
    <Parts>
      <BodyPart BodyPartSettings.FlavorDefault="html" />
    </Parts>
  </Metadata>
Default Recipe:
  <Metadata>
    <Types>
      <Page ContentTypeSettings.Draftable="True" TypeIndexing.Included="true">
        <TagsPart />
        <LocalizationPart />
      </Page>
      <BlogPost ContentTypeSettings.Draftable="True" TypeIndexing.Included="true">
        <CommentsPart />
        <TagsPart />
        <LocalizationPart />
      </BlogPost>
    </Types>
    <Parts>
      <BodyPart BodyPartSettings.FlavorDefault="html" />
    </Parts>
  </Metadata>
Now, how exactly to fix this post "cooking" is something I'm just not familiar with. Hoping some one can help me out.

 

Nov 14, 2011 at 2:21 AM

Self Solved but there is got to be a better way.  I enabled the Import/Export on a site with the Drafting Content Setting and sure enough I found the "feature" I needed:

-<BlogPost DisplayName="Blog Post" TypeIndexing.Included="true" ContentTypeSettings.Draftable="True">

But the site also had a lot of other missing features from my Core Recipe site.  I simply exported from my site, edited the xml and included the tags above and reimported.

it worked! Publish Now is available!

Now, please let me know figure out what the "proper way" of doing this....

'

Coordinator
Nov 15, 2011 at 1:06 AM

What are the exact steps that you followed? When you enabled Blogs, didn't it create the content types correctly?

Nov 15, 2011 at 1:25 AM
Edited Nov 15, 2011 at 1:26 AM

Thanks for the reply but I'm not sure I understand your question.  

I created a blog using the "Core Recipe".

I enabled the Blog Module after that.

New Blog posts didn't have "Publish Now" and through investigation I determined it was because the BlogPost type did not have the "Draftable="True" addtribute.

I found no way from within the UI to set this (why is there not a way to do this?)

To solve it, I creatively exported BlogPost contenttype from another instance that had been created with the "default recipe" which apparently has the XML within the recipe to make BlogPost a Draftable content type.  I then imported that into my instance which then set the Draftable flag in my "Core Recipe" creatd instance.

If there is a defect  it would be that enabling "Blog" module from the admin page of  "Core Recipe Install" doesn't appear to be setting "Draftable" on BlogPost content Types.

Within the ui, I would like to be able to set the Draftable and other flags regardless of what the default is.  I should be able to switch this on the fly and not have to rely on an import and export process or the default to set these flags.

 

Is this stored in the database somewhere?  If so, perhaps a module to be able to manage metadata on contentTypes is the appropriate answer.

 

Thanks for the assistance.

Coordinator
Nov 15, 2011 at 1:27 AM

Please file a bug in the issue tracker with these repro steps.

Nov 15, 2011 at 1:44 AM

I have opened a work item and included the workaround:

http://orchard.codeplex.com/workitem/18233

Feb 17, 2012 at 2:52 PM
Edited Feb 17, 2012 at 2:52 PM

Using release 1.3.10 I used the following statement in my Migrations.cs

 

		public int Create() {		
			ContentDefinitionManager.AlterTypeDefinition("Workshop", 
				cfg => cfg
					.WithPart("WorkshopPart")
					.WithPart("CommonPart")
					.WithPart("RoutePart")
					.WithPart("BodyPart")
					.WithPart("TagsPart")
					.WithPart("PublishLaterPart")
					.Creatable()
                                        .Draftable()
				);

			return 1;
		}

Note that I had to add the Draftable to the code in the initial Create method. Adding it in an upgrade method did not work for me. When I dived into the database I saw a difference between the two approaches:

When you do the code above you'll get this in the Settings_ContentTypeDefinitionRecord table

 

<settings ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" />

 

Let's say you forgot the Draftable() Type Setting and add it in an upgrade method then the table will contain two recors with

 
record1: <settings ContentTypeSettings.Creatable="True" />
record2: <settings ContentTypeSettings.Draftable="True" />

This seems similar for a human, but not for Orchard (yet :D)

Perhaps a design issue or maybe just a bug.

Coordinator
Feb 17, 2012 at 5:29 PM

Please open a bug for this, or enhance an existing one.

Thanks

Feb 17, 2012 at 5:43 PM
Edited Feb 17, 2012 at 5:43 PM
sebastienros wrote:

Please open a bug for this, or enhance an existing one.

Thanks

Added workitem 188444 (where I linked the workitem 18233 from corecomps)