What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
It worked well, without passing data from indexcontroller to twig. Looks like passing data to twig f
Comments
-
<?php /** * Copyright Β© 2016-present Spryker Systems GmbH. All rights reserved. * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. */ namespace Pyz\Yves\HelloWorld\Plugin\Router; use Spryker\Yves\Router\Plugin\RouteProvider\AbstractRouteProviderPlugin; use Spryker\Yves\Router\Route\RouteCollection; class HelloWorldPageRouteProviderPlugin extends AbstractRouteProviderPlugin { protected const ROUTE_HELLO_WORLD_INDEX = 'hello-world-index'; /** * Specification: * - Adds Routes to the RouteCollection. * * @api * * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection * * @return \Spryker\Yves\Router\Route\RouteCollection */ public function addRoutes(RouteCollection $routeCollection): RouteCollection { $routeCollection = $this->addHelloWorldIndexRoute($routeCollection); return $routeCollection; } /** * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection * * @return \Spryker\Yves\Router\Route\RouteCollection */ protected function addHelloWorldIndexRoute(RouteCollection $routeCollection): RouteCollection { $route = $this->buildRoute('/hello-world', 'HelloWorld', 'Index', 'indexAction'); $routeCollection->add(static::ROUTE_HELLO_WORLD_INDEX, $route); return $routeCollection; } }
0 -
@UPWG882P6 Another problem could be that you have to replace your twig file to another path
0 -
another path?
0 -
maybe the path to add the index.twig is not correct in the documentation
0 -
I got nearly the same problem, and I remember that I changed the file to another path and then it worked, I try to find out where
0 -
where did u change the path to?
0 -
okay I didnβt saw the path you had put your index.twig into, seems to be right, Let me try to figure out on my demo shop, maybe I figure it out
0 -
Path in controller has to fit the real path in project
0 -
Okay my example is working
0 -
return $this->view( $data, [], '@HelloWorld/views/index/index.twig' );
0 -
its still not working
0 -
now I used your Provider Class and changed the name to the file name
HelloWorldRouteProviderPlugin.php
withclass HelloWorldRouteProviderPlugin extends AbstractRouteProviderPlugin
0 -
maybe I share my stuff to you
0 -
ok
0 -
<?php /** * Copyright Β© 2016-present Spryker Systems GmbH. All rights reserved. * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. */ namespace Pyz\Yves\HelloWorld\Plugin\Router; use Spryker\Yves\Router\Plugin\RouteProvider\AbstractRouteProviderPlugin; use Spryker\Yves\Router\Route\RouteCollection; class HelloWorldRouteProviderPlugin extends AbstractRouteProviderPlugin { protected const ROUTE_HELLO_WORLD_INDEX = 'hello-world-index'; /** * Specification: * - Adds Routes to the RouteCollection. * * @param RouteCollection $routeCollection * * @return RouteCollection * @api * */ public function addRoutes(RouteCollection $routeCollection): RouteCollection { $routeCollection = $this->addHelloWorldIndexRoute($routeCollection); return $routeCollection; } /** * @param RouteCollection $routeCollection * * @return RouteCollection */ protected function addHelloWorldIndexRoute(RouteCollection $routeCollection): RouteCollection { $route = $this->buildRoute('/hello-world-test', 'HelloWorld', 'Index', 'indexAction'); $routeCollection->add(static::ROUTE_HELLO_WORLD_INDEX, $route); return $routeCollection; } }
0 -
Registered in
src/Pyz/Yves/Router/RouterDependencyProvider.php
like this: `namespace Pyz\Yves\Router; use Pyz\Yves\ExampleProductSalePage\Plugin\Router\ExampleProductSaleRouteProviderPlugin; use Pyz\Yves\HelloWorld\Plugin\Router\HelloWorldRouteProviderPlugin; ... protected function getRouteProvider(): array { return [ new ErrorPageRouteProviderPlugin(), new HomePageRouteProviderPlugin(), new CheckoutPageRouteProviderPlugin(), ... // here comes our plugin new HelloWorldRouteProviderPlugin(), ]; }
0 -
the Controller
IndexController.php
:<?php namespace Pyz\Yves\HelloWorld\Controller; use Spryker\Yves\Kernel\Controller\AbstractController; use Spryker\Yves\Kernel\View\View; use Symfony\Component\HttpFoundation\Request; class IndexController extends AbstractController { /** * @param Request $request * * @return View */ public function indexAction(Request $request) { $data = ['helloWorld' => 'Hello Worldklljkl!']; return $this->view( $data, [], '@HelloWorld/views/index/index.twig' ); } }
0 -
and the twig file
index.twig
:{% extends template('page-layout-main') %} {% define data = { helloWorld: _view.helloWorld } %} {% block content %} <div><h2>{{ data.helloWorld }}</h2></div> {% endblock %}
0 -
and executed:
$ docker/sdk cli npm run yves:watch # and in a second terminal tap $ docker/sdk console cache:empty-all
0 -
Am using vagrant
0 -
should not be that different
0 -
in your vagrant box I think it is possible to run
npm run yves:watch
0 -
I think you just have file name <-> class name differences which cause in that issue, but you canβt see it because you IDE doesnβt show you the misspelling (sniffers) or your vagrant box is caching all things as hell πΏ
0 -
but Iβm not that backend expert ^^
0 -
I corrected the filename
0 -
also replaced with your code, still the same
0 -
and the file name is the same like you named your class ?
0 -
yes
0 -
Okay, then let us check:
β’ file names for controller and plugin are the same like class names?
β’ the plugin is used and added tosrc/Pyz/Yves/Router/RouterDependencyProvider.php
correctly?
β’ you emptyed the caches?
β’ you called the new address: http://yves.de.spryker.local/hello-world-test ?
β’ -> I changed the /hello-world to /hello-world-test now at /hello-world should be a 404 Page not found0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random