-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Fixed numeric aliases 404 handling #1508
Merged
leofeyer
merged 1 commit into
contao:4.4
from
Toflar:fix-numeric-alias-with-non-dot-suffix
Jun 13, 2018
Merged
Fixed numeric aliases 404 handling #1508
leofeyer
merged 1 commit into
contao:4.4
from
Toflar:fix-numeric-alias-with-non-dot-suffix
Jun 13, 2018
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… or did not contain a dot
aschempp
approved these changes
May 1, 2018
|
Thank you @Toflar. |
leofeyer
pushed a commit
that referenced
this pull request
Jul 20, 2020
Description ----------- | Q | A | -----------------| --- | Fixed issues | #1508 | Docs PR or issue | contao/docs#468 *Updated description (20/07/08)* --- ### What's inside This PR ships… * … a Twig template + some helper functions (macros) to render a `Image\Studio\Figure` as a `<figure>` tag. This includes a picture + caption and is comparable to the `image.html5` template. * … a Twig function to directly render figures from within templates. The function accepts an optional custom template and a set of options that used to configure the `FigureBuilder`. * … as a bonus (idea © by @ausi 🙂 ) a function to create `PictureConfiguration`s from within templates. This enables building figures with custom size configurations per template. #### It enables the following scenarios: 1) Rendering the default template (from a Controller): ```php $figure = $studio->createFigureBuilder->from($uuid)->setSize(5)->build(); $twig->render('@ContaoCore/Image/Studio/figure.html.twig', ['figure' => $figure]); ``` 2) Rendering a custom template with a figure (using the 'figure' macro): ```php $twig->render('my_template.html.twig', [ 'headline' => $headline, 'my_figure' => $figure, ]); ``` ```twig {% import "@ContaoCore/Image/Studio/_macros.html.twig" as studio %} <h1>{{ headline }}</h1> <div class="container"> {{ studio.figure(my_figure) }} </div> ``` 3) Rendering a figure from within a template 🌟 (→ uses the default figure template): ```twig {{ contao_figure(uuid, [200, 200, 'crop'], { enableLightBox: true, lightBoxGroupIdentifier: 'foo', }) }} ``` 4) Rendering a figure from within a template using a custom figure template: ```html {{ contao_figure('path/to/an/image.png', '_mySize', { disableMetaData, }, '@app\my_custom_template.html.twig') }} ``` 5) Building a picture configuration on the fly (syntax equals definition from config): ```twig {% set special_config = picture_config({ width: 400, height: 400, resize_mode: 'crop', sizes: '0.75,1,1.5,2', items: [{ width: 200, height: 100, media: '(max-width: 140px)', }] }) %} {{ contao_figure(id, special_config) }} ``` 6) Building a figure template from building blocks: ```twig {% import "@ContaoCore/Image/Studio/_macros.html.twig" as studio %} <h3>Now look</h3> <figure class="my_custom_stuff"> <div class="caption-container"> {{ studio.caption(figure) }} </div> {{ studio.picture(figure) }} </div> ``` 7) Overwriting options inside the template: ```twig {% import "@ContaoCore/Image/Studio/_macros.html.twig" as studio %} {{ studio.figure(uuid, {}, { attr: { class: 'image-container' }, caption_attr: { class: 'caption', data-foo: 'bar' } } }} ``` This principle is borrowed from `symfony/form`. You can define options when creating a `Figure` but you can also specify them when building the template (overwriting the set ones). This makes the whole thing very flexible. Currently you can only define HTML attributes for the various tags but this can easily be extended by either the core or devs creating their own templates. Have a look in the macro file for a more detailed explanation how it is set up. ### Dependencies Note: This PR is currently based on #1753. The relevant changes are in the following folders: * `core-bundle\src\Twig\*` * `core-bundle\views\Image\*` * `core-bundle\Resources\config\services.yml` * `core-bundle\tests\Twig\*` (Commits starting from e76bf63295b6f5d2ff09fc17e74e463139bbb4ab) ### Todo * [x] Finish templates * [x] Tests * [x] Rebase once #1753 is merged Commits ------- 1877c6a5 add figure Twig template + helper macros f401a4ec add 'contao_figure' + 'picture_configuration' Twig functions 637c960e add microtags 7dfa1dbf improve naming 124cfe91 add tests b4497a05 allow dynamic property access for creating picture configurations (+ throw for unmapped keys) 164ba8ed reuse property accessor 65ffc143 allow overwriting meta data on the fly c287ab88 shorten 'picture_configuration' Twig function to 'picture_config' 7b5ea547 make 'size' an integral part of the 'render_figure' signature see contao/contao#1937 (comment) 03dfc35c Fix the coding style a70beef2 expect exceptions late 2f2bfcf9 remove backticks from twig comments 935bbb8f widen type to accept null 39d62485 use FQCN as service names 74310e3e improve property type hint
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When you don't have an url suffix configured or it does not start by a
., the current regex does not match and thus the 404 page is not shown but instead the content of the page is loaded.Steps to reproduce:
urlSuffixto be an empty string''.foobarand note your id (e.g.42)./42.Expected:
I expect to be redirected to the configured 404 page because the page id 42 has a configured alias
foobar.What happens:
I can see the content of page ID
42.