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

UPWG882P6
UPWG882P6 Posts: 140 πŸ§‘πŸ»β€πŸš€ - Cadet

It worked well, without passing data from indexcontroller to twig. Looks like passing data to twig file is failing. Can someone help.

"Template "@HelloWorld/views/index/index.twig" is not defined."
Β«13

Comments

  • how does the controller look like? and the path to the template?

  • UPWG882P6
    UPWG882P6 Posts: 140 πŸ§‘πŸ»β€πŸš€ - Cadet
    /**
     * @param \Symfony\Component\HttpFoundation\Request $request
     *
     * @return \Spryker\Yves\Kernel\View\View
     */
    public function indexAction(Request $request)
    {
        $data = ['helloWorld' => 'Hello Spryker!'];
        return $this->view(
            $data,
            [],
            '@HelloWorld/views/index/index.twig'
        );
    }
    
  • DOes the path of the index.twig as appears in the render view call?

  • UPWG882P6
    UPWG882P6 Posts: 140 πŸ§‘πŸ»β€πŸš€ - Cadet
    {% extends template('page-layout-main') %}
    {% define data= {
        helloWorld: _view.helloWorld
    } %}
    {% block content %}
        <div class="row">
            <div class="small-12 columns">
                <h2>{{ data.helloWorld }} </h2>
            </div>
        </div>
    {% endblock %}
    
  • UPWG882P6
    UPWG882P6 Posts: 140 πŸ§‘πŸ»β€πŸš€ - Cadet
    /**
     * @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;
    }
    
  • can you post a screenshot to the relevant file tree in the project?

  • the views/ directory is missing in the middle there

  • UPWG882P6
    UPWG882P6 Posts: 140 πŸ§‘πŸ»β€πŸš€ - Cadet

    Still the same error.. it didnt changed.

  • Unknown
    edited September 2020

    did you try to clear the cache? vendor/bin/console cache:empty-all

  • UPWG882P6
    UPWG882P6 Posts: 140 πŸ§‘πŸ»β€πŸš€ - Cadet

    Did it, still. the same

  • can you send a screenshot of the entire error message?

  • UPWG882P6
    UPWG882P6 Posts: 140 πŸ§‘πŸ»β€πŸš€ - Cadet

    sure

  • i am running out of obvious ideas here πŸ€”

  • also need to leave soon

  • UPWG882P6
    UPWG882P6 Posts: 140 πŸ§‘πŸ»β€πŸš€ - Cadet

    We can see tomorrow, I have leave too.

  • UPWG882P6
    UPWG882P6 Posts: 140 πŸ§‘πŸ»β€πŸš€ - Cadet

    Have a lovely evening.

  • thanks! you too! let’s solve it tomorrow!

  • good morning

  • fresh day, fresh luck! πŸ™‚

  • UPWG882P6
    UPWG882P6 Posts: 140 πŸ§‘πŸ»β€πŸš€ - Cadet

    Good morning, restarted my system, its the same .

  • U01AM1YGRC2
    U01AM1YGRC2 Posts: 71 πŸ§‘πŸ»β€πŸš€ - Cadet

    Hello πŸ™‚ ASAIK I did the same and had to register the RouteProviderPlugin to an Array. Also I had a bit trouble with the caching at the first time.

  • hi! thanks norman! i think we have the route provider correctly registered, because it tries to load the right template, but fails to do so

  • U01AM1YGRC2
    U01AM1YGRC2 Posts: 71 πŸ§‘πŸ»β€πŸš€ - Cadet

    src/Pyz/Yves/Router/RouterDependencyProvider.php

  • U01AM1YGRC2
    U01AM1YGRC2 Posts: 71 πŸ§‘πŸ»β€πŸš€ - Cadet

    Ah it fails at twig?

  • but can you please check, @UPWG882P6?

  • unfortunately i don’t have time before 1230 πŸ˜•

  • U01AM1YGRC2
    U01AM1YGRC2 Posts: 71 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UPWG882P6 I’m not sure about your HelloWorldRouteProviderPlugin, maybe you forgot to extend from the AbstractRouteProviderPlugin and use the addRoutes Method ? Like --> https://documentation.spryker.com/docs/tutorial-hello-world-scos