-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add snippet_selection Resolver #32
Add snippet_selection Resolver #32
Conversation
@TheCadien thx! It solved big problem in my project.
If you have lots of images in your snippet then response payload size increases singnificantly. Other resolvers deal with media files like this:
Using But even though it is really importand PR for me and I can finally use snippets in my headless SULU. Thx for that! |
@amb-jarek I will check that,I have to do unit tests anyway until we can finish that MR |
return new ContentView([]); | ||
} | ||
|
||
$content = $this->snippetResolver->resolve($data, $property, $locale, $attributes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that we can use the SnippetResolver here as we need to resolve every property itself e.g. the media need to be resolved over the MediaResolver and so on, but could not have a deeper look into just the first think which did come to my mind when scrolled over this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think your right !
change a lot to add the correct structure Resolver
@amb-jarek think the image output is much better now |
@TheCadien Did you test this solution with smart content?
I found that error is throwed by from SingleMediaSelectionResolver line: 42 where variable $data is string instead of array. |
Hi, I've tested these changes and it works for normal snippet selection. But when you use a default snippet it does not resolve the default snippet unfortunately. |
@alexandersch could you explain what you mean with "default snippet" and step by step way to reproduce ? Thanks ! :) |
Yes ofcourse. I've created a default snippet template based on the documentation. https://docs.sulu.io/en/2.0/cookbook/default-snippets.html. For example a 'footer' snippet with area 'footer'. Next, I've defined a 'snippet_selection' property in my page template. With parameters type='default' and default='footer'. Final step is to create a new footer snippet in the admin interface and then select it as a default snippet in the webspace's default snippets settings. Normally you would then get at least the default snippet in your twig template when you do a dump of 'content.footer' for example. I've made some changes to the StructureResolver as a workaround, but maybe that is not the correct solution for this. |
hey @TheCadien - first of all, thanks for your work on this! |
@nnatter sure ! |
Just tested this. The problem is not related to this PR. It would be nice if you could create new issue if the problem still affects you. |
Just pushed some changes that should hopefully fix the default-snippet issue and added some test cases. Would be nice to get some feedback regarding to the default-snippet before merging it 🙂 Thanks again for working on this @TheCadien |
@nnatter is this not what was fixed in #31? |
Unfortunately only partially. It looks like resolving properties via the |
I'll test the default snippet bit tonight. EDIT:
If I add the article property to these templates, it works as expected. The default snippet is outputted. |
@alexandersch Can you provide some context where this exception is thrown? |
@TheCadien @nnatter Thank you for providing this 👍 |
See #3