Skip to content

Instantly share code, notes, and snippets.

@smichaelsen
Last active December 16, 2015 10:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save smichaelsen/5419632 to your computer and use it in GitHub Desktop.
Save smichaelsen/5419632 to your computer and use it in GitHub Desktop.

Multiple sys_category fields in one table

When your table has more than 1 field with relations to sys_category you will run into problems because the MM relation table sys_category_record_mm will only store which table a category belongs to - but not the specific field.

You need to extend sys_category_record_mm like this:

Add the following to your extension's ext_tables.sql:

CREATE TABLE sys_category_record_mm (
	field_name varchar(255) DEFAULT '' NOT NULL
);

Use the extension manager to bring your SQL changes into effect.
Then adjust your makeCategorizable() calls to look like this:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable(
	'my_ext', // Your Extension key 
	'tx_myext_domain_model_mytable', // the table
	'categories', // the field name 
	array( // override the default configuration
		'fieldConfiguration' => array(
			'MM_match_fields' => array(
				'field_name' => 'categories' // the field name again
			)
		)
	)
);

-- Sebastian Michaelsen sebastian.michaelsen@t3seo.de
TYPO3 Freelancer

Creative Commons Lizenzvertrag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment