Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content element and front end module fragments not shown in select options #2415

Closed
fritzmg opened this issue Oct 7, 2020 · 12 comments · Fixed by #2417
Closed

Content element and front end module fragments not shown in select options #2415

fritzmg opened this issue Oct 7, 2020 · 12 comments · Fixed by #2417
Assignees
Labels
Milestone

Comments

@fritzmg
Copy link
Contributor

fritzmg commented Oct 7, 2020

Affected version(s)

Contao 4.10.3

Description

I can confirm this report. Content elements and front end modules implemented as fragments do not show up in the type selection anymore.

e.g.:

// src/Controller/ContentElement/ExampleElementController.php
namespace App\Controller\ContentElement;

use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController;
use Contao\CoreBundle\ServiceAnnotation\ContentElement;
use Contao\ContentModel;
use Contao\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * @ContentElement(category="texts")
 */
class ExampleElementController extends AbstractContentElementController
{
    protected function getResponse(Template $template, ContentModel $model, Request $request): ?Response
    {
        return new Response('Hello World!');
    }
}
// src/Controller/FrontendModule/ExampleModuleController.php
namespace App\Controller\FrontendModule;

use Contao\CoreBundle\Controller\FrontendModule\AbstractFrontendModuleController;
use Contao\CoreBundle\ServiceAnnotation\FrontendModule;
use Contao\ModuleModel;
use Contao\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * @FrontendModule(category="miscellaneous")
 */
class ExampleModuleController extends AbstractFrontendModuleController
{
    protected function getResponse(Template $template, ModuleModel $model, Request $request): ?Response
    {
        return new Response('Hello World!');
    }
}

Switching back to Contao 4.10.2 shows example_element/example_module as an available option in the respective categories.

@aschempp
Copy link
Member

aschempp commented Oct 7, 2020

does it work in the latest Contao 4.9 release? Because that should be the same implementation…

@fritzmg
Copy link
Contributor Author

fritzmg commented Oct 7, 2020

Yes, it works in Contao 4.9.8.

@dmolineus
Copy link
Contributor

Guess it's caused by f7c15c0#diff-a6384623b2493a3d08b3efb4386464e6L103

@leofeyer
Copy link
Member

leofeyer commented Oct 7, 2020

Can you test if reverting the changes from #2372 fixes the issue?

@fritzmg
Copy link
Contributor Author

fritzmg commented Oct 7, 2020

Can you test if reverting the changes from #2372 fixes the issue?

Yes, that helps.

@leofeyer
Copy link
Member

leofeyer commented Oct 8, 2020

@aschempp Did you remove the $childDefinition->addTag() call accidentally?

@aschempp
Copy link
Member

aschempp commented Oct 9, 2020

see #2417 for my suggested fix.

@aschempp aschempp closed this as completed Oct 9, 2020
@leofeyer leofeyer linked a pull request Oct 9, 2020 that will close this issue
@Kahmoon
Copy link

Kahmoon commented Oct 12, 2020

Good morning,

is there acutally a workaround until an update will come out? A live installation doesn´t load modules :-( (didn´t recognize it when updating from the dev system).

greetz

@fritzmg
Copy link
Contributor Author

fritzmg commented Oct 12, 2020

You could downgrade to Contao 4.10.2.

@Kahmoon
Copy link

Kahmoon commented Oct 12, 2020

hmm thats a bit risky....any idea when this issue probably will be fixed? At 4.10.2 the is a bug with file extensions in uppercase .JPG which also affects my installation a lot ;). Also you cannot change file extension in contao file management. When i do this via ftp...all placements of this images are lost.

Downgrade would be to enter 4.10.2 manually instead of 4.10.* and update all packages?

@fritzmg
Copy link
Contributor Author

fritzmg commented Oct 12, 2020

You could also revert the changes from #2372, specifically the change within RegisterFragmentsPass.php.

@Kahmoon
Copy link

Kahmoon commented Oct 12, 2020

I will try that.

I added the code line in RegisterFragmentsPass.php
$childDefinition->addTag($tag, $attributes);

My frontend modules are working again. Thx!

leofeyer pushed a commit that referenced this issue Oct 15, 2020
Description
-----------

This fixes the issue in #2415
The changes are not _necessary_ for Contao 4.9, but I would merge it here for consistency. I don't know why we had two separate compiler passes for the same thing… 

additionally the `RegisterFragmentsPass` is _meant_ to be used by third-party developers to register additional fragment types. This now allows to register them in the globals as well.

Commits
-------

ddec13d Register globals in fragment pass
b9a4fd3 Migrate tests
9e83db2 Move the expected exception
0099dd2 Correctly re-add child definition tags
e643ea5 Added unit tests for copying service tags
leofeyer pushed a commit to contao/core-bundle that referenced this issue Oct 15, 2020
Description
-----------

This fixes the issue in contao/contao#2415
The changes are not _necessary_ for Contao 4.9, but I would merge it here for consistency. I don't know why we had two separate compiler passes for the same thing… 

additionally the `RegisterFragmentsPass` is _meant_ to be used by third-party developers to register additional fragment types. This now allows to register them in the globals as well.

Commits
-------

ddec13da Register globals in fragment pass
b9a4fd32 Migrate tests
9e83db2b Move the expected exception
0099dd2c Correctly re-add child definition tags
e643ea52 Added unit tests for copying service tags
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants