Products sample and Publish/Draft buttons
Hello,
I'am little confused about tool bar in Products sample (Details view). It has "Publish" and "Save as Draft" buttons. But is I check ProductsDefinitions.cs -> CreateBackendFormToolbar function it says following:
// Create
toolbarSectionElement.Items.Add(
new
CommandWidgetElement(toolbarSectionElement.Items)
Name =
"SaveChangesWidgetElement"
,
ButtonType = CommandButtonType.Save,
CommandName = DefinitionsHelper.SaveCommandName,
Text = (isCreateMode) ? String.Concat(
"Create"
, itemName) :
"SaveChanges"
,
ResourceClassId = resourceClassId,
WrapperTagKey = HtmlTextWriterTag.Span,
WidgetType =
typeof
(CommandWidget)
);
Any ideas on this?
Also I found that my data item has following property overridden:
public
override
bool
SupportsContentLifecycle
get
return
false
;
Hi Denis,
The Products sample in our SDK is a full blown content based module which supports almost all features of the built-in modules. One of them is workflow. The confusion comes, because in the user interface, all buttons that you see are actually related to the workflow.
Although you have definitions for "Save as Draft", those definitions are not applied if workflow is supported. Instead, the buttons which should be displayed are shown as the result of a service call that you can see if you inspect the network traffic in Firebug. That said, if you want to modify those buttons, you would have to switch workflow off.
The SupportContentLifecycle property is not overriden anywhere in Products. Maybe you've followed another of our tutorials where we don't use workflow?
Hi Slavo,
Thank you for the reply.
I created my custom module based on the following tutorial:
http://www.sitefinity.com/blogs/joshmorales/posts/11-07-07/creating_sitefinity_4_content_modules_part_1_project_preparation_and_hello_world.aspx
It doesn't show how to add Publish/Draft functionality. I'm trying to figure out what I should add to support "Publish/Draft" functionality.
I tried to review Products sample, but it contains a way more features and it is hard to extract only what I need. I want to extend my module gradually.
So far I implemented LifecycleDecoratorWrapper for my service
Item implements ILifecycleDataItemGeneric
ItemsManager implements ILifecycleManager
Could you please let me know what new interfaces/functions need to be supported in order to have "Publish/Draft" functionality?
I don't sure if I need workflow functionality for right now. But if it is tied to "Publish/Draft" functionality, I'm fine to support workflow feature as well.
Thanks!
Denis.
Hi Denis,
If you want your module data items to behave like the default modules, you have to implement both content lifecycle and workflow. To implement lifecycle, what you've already done is enough. Of course you should remove the SupportContentLifecycle property, or return true from its getter.
To support workflow, there are a number of steps you need to take.
Before I describe the steps, I want to mention that the easiest way to achieve this scenario in Sitefinity 4.4 is using the Module Builder. With that feature, you can do all this work though the UI and items support publish/draft versions by default. For more information, please go to http://www.sitefinity.com/asp-net-cms-for-developers/module-builder.aspx
If you still decide to implement workflow yourself, here are the steps:
1. Copy the ProductsWorkflow.xamlx file from the Products module to your module's assembly. Make the file an embedded resource.
2. In your data item, implement the IApprovalWorkflowItem interface. This is essentially including two properties, like ProductItem class - ApprovalWorkflowState and ApprovalTrackingRecordMap.
3. In your module class, add a property for the workflow URL, called WorkflowRelativeURL. See the ProductsModule.cs.
4. In the same module class, copy the InstallCustomWorkflow() method. Substitute the ProductItem class in the code with your data model. Do the same with ProductResources class.
5. Call the InstallCustomWorkflow() method from the Install() method.
After all this you need to reinstall your module for the changes to take effect. For all the steps above you can take a look at the implementation in the ProductsModule for details. If you have questions for the details of this implementation, contact us again.
Hi Slavo,
I've done all steps you suggested in the previous message.
Additionally, I added following line in the FluentMapping->MapItem method:
itemMapping.HasAssociation<Telerik.Sitefinity.Workflow.Model.Tracking.ApprovalTrackingRecordMap>(p => p.ApprovalTrackingRecordMap);
Hello,
It looks like the content lifecycle is working, but workflow is not.
From what I see the problem is related to the service which is invoked. Either the service fails or it cannot find the workflow file. The problem is related to step 1 or 3 from my previous post. When you open the edit screen, a call is made to the workflow service. You can take a look at the request in your browser's web development tools (as shown in the attached image), and see if this call returns ok.
Please send back the result from the call. If it is not OK, the log file may contain info about what exactly failed.