# Allow Duplicated Files In Collection

By default, the system prevents files from being inserted multiple times in the same collection. If this behaviour is not intended this protection can be deactivated as follows.

# 1. Index Overwriting

Place an index config with the name unique_item.4apdbindex in the directory custom/modules/f_collection_item/index. The unique parameter in the config should be set to false as shown below.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<db_index>
    <fields>
        <field>collection</field>
        <field>file</field>
    </fields>
    <type>Binarytree</type>
    <unique>false</unique>
</db_index>

This config overwrites the index that is ensuring the uniqueness in the module.

# 2. Hook Disabling

Deactivate or overwrite the f_collection_item_exists_hook.4aphook in the directory custom/modules/f_collection_item/plugins/server_hooks . The content of the file should be an empty hook config:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <hooks>  </hooks>
</root>

This Hook resolves conflicts e.g. if multiple files are inserted and a portion of them do already exist. If this hook is deactivated the system does not guarantee a meaningful order of the freshly inserted files.

# 3. Remove Index If Necessary

If the unique index was already created can be checked with the following statements:

Mysql: SHOW INDEX FROM f_collection_item FROM 4allportal

Mssql: EXEC sp_helpindex '4allportal.dbo.f_collection_item'

Entries with the name f_collection_item_unique_item_DBI need to be deleted:

Mysql: DROP INDEX f_collection_item_unique_item_DBI ON f_collection_item

Mssql: DROP INDEX f_collection_item.f_collection_item_unique_item_DBI

Request missing documentation