Modifying Text Files

Modify text-like files on the website with the file modify package fragment installer

The FileModifyPackageFragmentInstaller appends content to text and text-like files. For example, using this fragment installer you can add styles to the end of a CSS file.

If the target file doesn't exist, you can choose the way the installer handles this case. The installation can either continue with or without creating the file, or fail.

Please note that uninstalling the package will not lead to removing the appended content, nor deleting the file if the latter has been created during the installation.

	installerType="Composite.Core.PackageSystem.PackageFragmentInstallers.FileModifyPackageFragmentInstaller, Composite"
	uninstallerType="Composite.Core.PackageSystem.PackageFragmentInstallers.FileModifyPackageFragmentUninstaller, Composite">
		<!-- whenNotExist="fail,create,ignore" -->
    <AppendText path="~/Frontend/Styles/fancy.css" whenNotExist="create">
        Line 1
        Line 2
        Line 3

The <mi:Add> element can contain one or more AppendText elements.

The AppendText element should contain the text to append to the target file. The content between <AppendText> and </AppendText> will be treated as pre-formatted content (like within <pre></pre>)

The AppendText element has the following attributes:

  • path: A tilde-based path that points to a file location on the C1 CMS file structure.
  • whenNotExist: A flag that indicates the way the installation proceed if the target file does not exist:
    • fail: The installation fails
    • create: The target file is created and the specified content is added to it.
    • ignore: The installation continues without creating a file.