What is best practice for the Package Creator to either require a dependency of another package, i.e. the Forms Rendering package, or install the required dependency. The configuration packages are available from Package Creator but that appears tedious if a package has numerous config items.
相关问题
- How to add a timestamp field using Composite C1?
- Composite C1 pages cannot be saved [closed]
- Package Creator - Require a Dependency
- Handle content in usercontrols through CMS?
- Configure TinyMCE for use of Font Awesome icons in
The current release of Composite C1 Package Creator (v.3.3) do not have features for specifying required packages via the UI. I suggest you register a feature request for this and describe your need. You can use 'Create New Item' on http://compositec1.codeplex.com/workitem/list/basic
Writing custom validation logic
With some C# development you can add this check to a package though. The C1 Package system is based on 'installer plug-ins' that validate state before install and do the install work. You can write such an 'installer plug-in' and make it validate the presence of a required C1 Package and then associate your plug-in with your package.
Create a class that inherit from
Composite.Core.PackageSystem.PackageFragmentInstallers.BasePackageFragmentInstaller
Override Install() and Validate() - put your validation into Validate() and return one or more PackageFragmentValidationResult is your validation fails. Let Install() simply return.
Register your new 'fragment installer' class in the packages install.xml file - add a section like this inside the root element:
<mi:PackageFragmentInstallerBinaries> <mi:Add path="~/MyAssembly.dll"/> </mi:PackageFragmentInstallerBinaries>
where path points to your assembly as you added it to the zip.
Inside the existing
<PackageFragmentInstallers />
element, add calls to your class inheriting fromBasePackageFragmentInstaller
by using an element like<mi:Add installerType="MyFragmentInstallers.MyValidator, MyFragmentInstallers"/>
Doing this will make Composite C1 call your Validate() method as part of the package install, and alert the user if any validation messages are returned.
Detecting if a package is installed
If you know the ID of a package, you can check if it has been installed using
Composite.Core.PackageSystem.PackageManager.IsInstalled(Guid packageId)
.