Jump to content

Extending FieldtypeModule


Recommended Posts

Is there a certain reason, why there is no way to add a module reference field through the usual field creation process in backend? It doesen't appear in the list. I'm aware of the fact that it mostly stores process modules for backend. Nevertheless there are some cases when a module reference field is a nice thing to have in frontend pages.

Lately I tried to create a Fieldtype extending FieldtypeModule, but the extension failed because of the order the modules are loaded depending on their status flags.

So there is no way to make the module reference field accessable for field setup but by changing status flags manually or creating a copy of the fieldtype with a different status flag?

Link to comment
Share on other sites

However, I'm not sure you really want to use that fieldtype as it is limited to special types of modules based on the parent class.

May I suggest using a regular page field with ASM select inputfield or alike, and create pages for each module you want to be able to select. Then use the title on those pages to load the module in the frontend. So you could even have multiple modules and sort them the way you want them to load. Depends on what you're up to.

// when multiple select

foreach($pages->selected_modules as $mod) {
 $module = $modules->get($mod->title);

//or just a single select

$module = $modules->get($page->selected_module->title);
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...