SuiteCRM 8.x custom module legacy view

Hello,

I am trying to adapt old (SuiteCRM 7.x) custom module to new (SuiteCRM 8.x) CRM. It seems all fine, but there is one thing that is making issue (doesn’t load module legacy list view). I added module_routing.php file to ../../extensions/<module_name>/config/module_routing.php path to load module legacy listview and is working good, but if I enable PackageScanner or try to upload module to SuiteCRM Store it’s not allowed, because of ../../.

According to SuiteCRM 8.x documentation (Extension Structure :: SuiteCRM Documentation) there are at least two ways how to set up extension changes:

  1. ./public/extensions/<extension_name>/config/
  2. ./extensions/<extension_name>/config/

But only one way is activating module_routing.php and makes effect. What can I do, to allow PackageScanner and SuiteCRM Store to upload this module?

The file module_routing.php contains following code:

<?php

use Symfony\Component\DependencyInjection\Container;

if (!isset($container)) {
    return;
}

/** @var Container $container */
$routes= $container->getParameter('legacy.module_routing') ?? [];

$routes['module_name'] = [
    'index' => false,
    'list' => false,
    'record' => false
];


$container->setParameter('legacy.module_routing', $routes);

The manifest.php file $installdefs variable contains following copy path:

$installdefs["copy"][] = array(
    'from' => '<basepath>/extensions/<module_name>/config/module_routing.php',
    'to' => '../../extensions/<module_name>/config/module_routing.php',
);

Thank you!

What is package scanner?

Why are you trying to use v8-style extensions if you just want a legacy thing? I don’t know exactly what your needs are, or how all of this should be done, but I would try to start with something simpler.

If you just put your module in the usual place, under “public/legacy”, what happens? Is this a purely custom module, or is it a customized core module?

Hello!

Thank you for reply! The Package Scanner ir SugarCRM component which can be enabled in config.php (more documentation in: Module Loader Restrictions - Sugar Support)

I am trying to make custom module compatible with SuiteCRM 8.x and therefore it seems to be working, but only when enabling legacy list view in not allowed location. This means that there should be some way how to make legacy list view in compatible/safe way. Can you please help with that?

Thank you!

Don’t use Symfony extensions, just place the module in the normal place under public/legacy, and then tell me exactly what goes wrong.

Hello,

Thank you for your reply. I made simplified custom module which you can download and install (https://file.io/YnsUG2g7yDeH). There are no functionality, only possibility to show ./modules/CustomModule/views/view.list.tpl which should show text We want to show this view when using module list view from ./modules/CustomModule/templates/main.tpl.

Hope this will show up what’s going on. Thank you!

extensions is a Symfony directory, for SuiteCRM v8

modules is a SuiteCRM v7 directory, in v8 it appears inside public/legacy

You’re just mixing two things.

Thank you for clarifying. The problem is that when I use only SuiteCRM v7 approach, then module list view is not displayed in SuiteCRM 8.x. I attached file (https://file.io/a3nZXFUTfwbc) where is no extensions directory with module_routing.php file. It doesn’t work either. When accessing CustomModule from SuiteCRM 8.x top menu it shows native list view with error Error occured while retrieving records. While I need to display custom view. Is there any chance to get it working without mixing?

Sorry, I don’t have time to try your files.

Also, I am new to this scenario - I don’t really know the answers.

I would try creating a new custom module in v8, using Module builder. Do it under source control (git), then examine which files were created or changed. Then when you have that working, try putting your code inside that “skeleton”.

Good luck

Thank you for your advice. Before I wrote this question I followed solutions from forum (this is why I “mixed”):

  1. Compatibility mode in suitecrm 8? - #6 by wondertrout
  2. SuiteCrm 8: problems with customizations - #36 by pgtuy1

What you offer is to use Module Builder from SuiteCRM Administraton section, but it’s creating “standartised” module with default list view. I need to address SuiteCRM 8.x module menu entry to custom list view. Maybe there is some method how I can rewrite the module menu link to show up custom action (probably I could duplicate action_listview)?

Maybe someone can give advice/solution? I think this can affect many users.

This is almost correct, however as pgr says there is a difference between Symfony extensions and Legacy Modules, to do what you are asking you actually need your Legacy module installed in public/legacy/modules/ AND an extension in the top level extensions folder (just above public)
so:
extensions/MySymfonyExtension/config/module_routing.php
public/legacy/modules/NewLegacyModule

Then in module_routing.php you do the following:

<?php

use Symfony\Component\DependencyInjection\Container;

if (!isset($container)) {
    return;
}

/** @var Container $container */
$routes= $container->getParameter('legacy.module_routing') ?? [];

$routes['NewLegacyModule'] = [
    'index' => false,
    'list' => false,
    'record' => false
];


$container->setParameter('legacy.module_routing', $routes);

The you need to do a php bin/console cache:clear AND an R&R in the admin panel ensure your permissions are correct etc.

Please note that the name of the SymfonyExtension must follow PSR so no - etc in the name. Also the name of NewLegacyModule should match the name of your module exactly (case as well).

Regards

Mark

Thank you for reply. It seems the same as my offered sample. What am I missing?

Is this an Installer question or a module_routing question? ie have you tried placing these files into a fully working Suite8 install?

$routes['NewLegacyModule'] = [
    'index' => false,
    'list' => false,
    'record' => false
];

The word NewLegacyModule here should match (case etc) your Suite7 module placed in the legacy folder (I believe it should be the module name ie AOS_Quotes not necessairly the folder name -which is normally the same but can be different).

Your temporary download is gone so I cant check the actual files.

I can tell you the above works for me (we created a help module that uses the conditions from the workflow module that absolutely requires legacy mode to display them).

Mark

Thank you for reply. Actually this is question how to do it in right way. I attached temporary file to the current post: Filebin | hygxdtkdsr7x991a
If you have time, please, comment it - maybe it should be done in different way?

Looks mostly okay, as a project package however I think I saw an issue somewhere (that others mentioned) about the copy command not being able to copy outside of the legacy folder (ie the Symfony Extension), there is a post process command (see the docs.suitecrm.com) where you can add a php script to run after processing, I would suggest you try copying your Symfony module into place manually with a PHP script rather than the manifest.php installer.

I havent actually used the installer with Suite8 apps (we are developing here with git and applying the files directly).

The actual code looks okay though, have you tried putting them in place on a stock Suite8 install?
Regards

Mark