Skip to content

Commit

Permalink
Update add-custom-page.md
Browse files Browse the repository at this point in the history
- fix broken anchor links
- add additional info regarding necessary adjustments of the page-loader to the `services.xml`, which are needed to follow the guide and not (https://forum.shopware.com/t/add-custom-page-dokumentation-too-few-arguments/88072)[get stuck]
  • Loading branch information
jrson83 authored Nov 13, 2024
1 parent 69266ed commit 1daa8d9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions guides/plugins/plugins/storefront/add-custom-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ExampleController extends StorefrontController

It has a method `examplePage`, which is accessible via the route `example-page`. This method will be responsible for loading your page later on, but we'll leave it like that for now.

Don't forget to [register your controller via the DI](add-custom-controller#Services.xml%20example).
Don't forget to [register your controller via the DI](add-custom-controller#services-xml-example).

### Creating the pageloader

Expand Down Expand Up @@ -162,6 +162,23 @@ class ExampleController extends StorefrontController

Note, that we've added the page to the template variables.

#### Adjusting the services.xml

In addition, it is necessary to pass the argument with the ID of the `ExamplePageLoader` class to the [configuration ](add-custom-controller#services-xml-example) of the controller service in the `services.xml`.

```html

Check warning on line 169 in guides/plugins/plugins/storefront/add-custom-page.md

View workflow job for this annotation

GitHub Actions / Runner

[LanguageTool] reported by reviewdog 🐶 File types are normally capitalized. (FILE_EXTENSIONS_CASE[1]) Suggestions: `HTML` URL: https://languagetool.org/insights/post/spelling-capital-letters/ Rule: https://community.languagetool.org/rule/show/FILE_EXTENSIONS_CASE?lang=en-US&subId=1 Category: CASING Raw Output: guides/plugins/plugins/storefront/add-custom-page.md:169:3: File types are normally capitalized. (FILE_EXTENSIONS_CASE[1]) Suggestions: `HTML` URL: https://languagetool.org/insights/post/spelling-capital-letters/ Rule: https://community.languagetool.org/rule/show/FILE_EXTENSIONS_CASE?lang=en-US&subId=1 Category: CASING
// <plugin root>/src/Resources/config/services.xml
<service id="Swag\BasicExample\Storefront\Controller\ExampleController" public="true">
<argument type="service" id="Swag\BasicExample\Storefront\Page\Example\ExamplePageLoader" />
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
<call method="setTwig">
<argument type="service" id="twig"/>
</call>
</service>
```

### Creating the example page

So now we're going to create the example page class, that was already used in our page loader, `ExamplePage`.
Expand Down Expand Up @@ -195,7 +212,7 @@ class ExamplePage extends Page
}
```

As explained in the page loader section, your page can contain all kinds of custom data. It has to provide a getter and a setter for the custom data, so it can be applied and read. In this example, the entity from our guide about [creating custom complex data](../framework/data-handling/add-custom-complex-data#Entity%20class) is being used.
As explained in the page loader section, your page can contain all kinds of custom data. It has to provide a getter and a setter for the custom data, so it can be applied and read. In this example, the entity from our guide about [creating custom complex data](../framework/data-handling/add-custom-complex-data#entity-class) is being used.

And that's it already. Your page is ready to go.

Expand Down

0 comments on commit 1daa8d9

Please sign in to comment.