Creating a Custom Module for a Custom Frontend Page in Spryker

Blog
Spread the love

To create a custom module for a custom frontend page in Spryker, follow these steps. This module will handle a simple “Custom Page” that displays a message. Here’s a detailed breakdown of the steps:

Step 1: Create CustomPageFactory.php

Create the factory class in src/Pyz/Yves/CustomPage/CustomPageFactory.php

Step 2: Create CustomPageDependencyProvider.php

This file defines the dependencies for the module. It should be placed in src/Pyz/Yves/CustomPage/CustomPageDependencyProvider.php

Step 3: Create the Twig Template for the Custom Page

Next, you need to create a view template file that will render the custom page in your theme. This file goes in src/Pyz/Yves/CustomPage/Theme/default/views/custom/custom.twig

Step 4: Define a Custom Controller in CustomPageControllerProvider.php

The next step is to define a controller that will handle the route for the custom page. Create the controller provider in src/Pyz/Yves/CustomPage/Plugin/Provider/CustomPageControllerProvider.php

Step 5: Add Routes via CustomPageRouteProviderPlugin.php

Create a route provider plugin to add the route for your custom page. This will be in src/Pyz/Yves/CustomPage/Plugin/Router/CustomPageRouteProviderPlugin.php

Step 6: Create the Controller

The IndexController.php should be placed in src/Pyz/Yves/CustomPage/Controller/IndexController.php.

This controller will render the custom page with the template.

Step 7: Modify RouterDependencyProvider.php

Ensure that the CustomPageRouteProviderPlugin is added to the RouterDependencyProvider. Update src/Pyz/Yves/Router/RouterDependencyProvider.php as follows:

Step 8: Clear Cache and Rebuild

Finally, run the following command to clear the cache and re-enable the modules:

docker/sdk cli

console c:e,

To access the custom page you just created in Spryker, open your browser and navigate to the following URL:http://yves.us.spryker.local/en/custom-page

img

Final Thoughts:

By following these steps, you’ve created a custom module that displays a custom page at /custom-page. This page will use a Twig template to render a simple message.

Make sure to adjust the route, controller logic, and views as needed for your specific business logic.

bluethinkinc_blog

bluethinkinc_blog

2025-03-28

0

Leave a Reply

Your email address will not be published. Required fields are marked *

Find More Blogs

PODMAN

Spread the love 1.Introduction Podman: The Modern Container

Running Your Java Program (JAR) 24/7 on AWS EC2 Automatically

Spread the love Introduction Running a Java application

Building a REST API with Spring Boot

Spread the love Introduction REST (Representational State

Custom API to Fetch Customer Data by Customer ID in Spryker

Spread the love Introduction In this blog post, we will

Creating a Custom Module for a Custom Frontend Page in Spryker

Spread the love To create a custom module for a custom

How to create custom module api get category list without access token in Spryker

Spread the love To create a custom API for fetching a

Creating a Custom Glue API in Spryker

Spread the love Spryker’s Glue API is a powerful tool

Get AI Generated 360-Degree View of Account Summary in Dynamics 365 Sales

Spread the love Navigating the demanding landscape of sales

Enhancing Productivity with Dynamics 365: The Power of Session Restore

Spread the love Enhancing Productivity with Dynamics 365:

Salesforce Admin

Spread the love In our last blog, we discussed common

bluethinkinc Blogs