Attach items to content pages from within your module

Postdate: January 28 2012
Category: Module Creation
Applies to: 2.x

Sometimes it's useful to attach an item to one or more content pages like showing clients, logos or other additional information in a sidebar or below the main content.


Of course you could use GBCs for the task, but GBCs are always loaded and this could become an issue if you have a lot of them, and you never know which block is assigned to which page.

So what we want is a multiple select field to choose the contentpages from.

First step

 Open the CTLMM-file reservedwords.php and remove the line containing: 'content'

Everything starts with the module creation 

When creating fields for your final items(the entity),
create a field called: showonpage 
of type: dropdown (with multiple choices)

Enter the values

Name of option table: content
Field to use as option value: content_id
Field to use as option label: menu_text

Screenshot

 Screenshot

That's it!

Don't forget to add showonpage to your admin listview. This way you can see the contentpages which are assignd to the item.